利用74HC138和74HC595驱动16*16点阵完成上下左右滚动的功能的51单片机程序 100
2个回答
推荐于2017-05-17
展开全部
这是16X16的,自己一改就好了
//74HC595练习程序
//串入并出实现16流水灯效果
//2009.12.28
#includereg52.h
sbit shcp=P2^0; //数据在上升沿进入移位寄存器
sbit date1=P2^1; //串行数据输入端
sbit clock=P2^2; //上升沿时将数据输出到并行端口
unsigned char tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
unsigned char tab1[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void delay(unsigned int delay)
{
unsigned char i;
for(;delay0;delay--)
for(i=0;i125;i++);
}
void send_data(unsigned char date) //发送数据
{
unsigned char i;
for(i=0;i8;i++) //把每一位数据移入寄存器
{
shcp=0;
date=date1;
date1=CY;
shcp=1;
delay(20);
}
}
void main()
{
unsigned char k;
for(k=0;k16;k++)
{
send_data(tab[k]);
send_data(tab1[k]);
{clock=0;clock=1;};
}
}
//74HC595练习程序
//串入并出实现16流水灯效果
//2009.12.28
#includereg52.h
sbit shcp=P2^0; //数据在上升沿进入移位寄存器
sbit date1=P2^1; //串行数据输入端
sbit clock=P2^2; //上升沿时将数据输出到并行端口
unsigned char tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
unsigned char tab1[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void delay(unsigned int delay)
{
unsigned char i;
for(;delay0;delay--)
for(i=0;i125;i++);
}
void send_data(unsigned char date) //发送数据
{
unsigned char i;
for(i=0;i8;i++) //把每一位数据移入寄存器
{
shcp=0;
date=date1;
date1=CY;
shcp=1;
delay(20);
}
}
void main()
{
unsigned char k;
for(k=0;k16;k++)
{
send_data(tab[k]);
send_data(tab1[k]);
{clock=0;clock=1;};
}
}
更多追问追答
追问
好像不是我要的
追答
我再查查
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询