这是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;};
}
}
。。。