我最近做了一个16*64点阵的小东西,要求逐行滚动显示出“长江大学欢迎你”七个字,显示没问题,但滚动实在没想到好的方法,求各位大侠赐教。电路中使用8个74HC595串联起来做列驱动,用两个74HC573做行驱动,具体的连接方法在程序中都体现出来了。
#include <reg52.h>
sbit SHCP=P1^0;
sbit DS=P1^1;
sbit STCP=P1^2;
sbit OE=P1^3;
sbit LE=P1^4;
unsigned char i,j,k,flag;
unsigned char temp;
unsigned char code X_table[16][14]={0x08,0x00,0x40,0x00,0x01,0x00,0x22,0x08,0x00,0x40,0x00,0x00,0x08,0x80,
0x08,0x10,0x30,0x04,0x01,0x00,0x11,0x08,0x00,0x40,0x20,0xc2,0x08,0x80,
0x08,0x30,0x17,0xfc,0x01,0x00,0x11,0x10,0xfe,0x40,0x13,0x3f,0x08,0x80,
0x08,0x40,0x00,0x40,0x01,0x00,0x00,0x20,0x02,0x7e,0x0a,0x22,0x11,0xfe,
0x08,0x80,0x80,0x40,0x01,0x04,0x7f,0xfe,0x22,0x82,0x02,0x22,0x11,0x02,
0x09,0x00,0x60,0x40,0xff,0xfe,0x40,0x02,0x23,0x24,0x02,0x22,0x32,0x04,
0x80,0x40,0x20,0x40,0x01,0x00,0x80,0x04,0x14,0x20,0xfa,0x22,0xd4,0x20,
0xff,0xfe,0x08,0x40,0x02,0x80,0x1f,0xe0,0x14,0x20,0x0a,0x62,0x10,0x20,
0x09,0x00,0x10,0x40,0x02,0x80,0x00,0x40,0x04,0x20,0x0a,0xa2,0x10,0xa8,
0x09,0x00,0x20,0x40,0x02,0x40,0x01,0x84,0x14,0x20,0x0b,0x2a,0x10,0xa4,
0x08,0x80,0xe0,0x40,0x04,0x40,0xff,0xfe,0x12,0x50,0x0a,0x24,0x11,0x26,
0x08,0x40,0x20,0x40,0x04,0x20,0x01,0x00,0x22,0x50,0x08,0x20,0x12,0x22,
0x08,0x20,0x20,0x44,0x08,0x10,0x01,0x00,0xc0,0x88,0x08,0x20,0x10,0x20,
0x09,0x1c,0x2f,0xfe,0x10,0x0e,0x01,0x00,0x00,0x84,0x14,0x23,0x10,0x20,
0x0e,0x08,0x20,0x00,0x60,0x04,0x05,0x00,0x00,0x17,0x23,0xfe,0x10,0xa0,
0x08,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x06,0x02,0x00,0x00,0x10,0x40
}; //长江大学欢迎你
unsigned int code Y_table[]={0xfffe,0xfffd,0xfffb,0xfff7,0xffef,0xffdf,0xffbf,0xff7f,0xfeff,0xfdff,0xfbff,0xf7ff,0xefff,0xdfff,0xbfff,0x7fff};
void select(unsigned char a[14])
{
int i,j;
//unsigned char temp;
for(j=0;j<14;j++)
{
temp=a[13-j];
for(i=0;i<8;i++)
{
//if(j*8+i+k<112){
SHCP=0;
DS=temp&1;
temp=temp>>1;
SHCP=1;//}
}
}
}
void operate(unsigned int a)
{
P2=a%256;
P3=a/256;
}
void main()
{
i=0;
j=0;
k=0;
flag=0;
LE=1;
select(X_table[0]);
TMOD=0x01;
TH0=(65535-1000)/256;
TL0=(65535-1000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(flag==1)
{
OE=1;//消隐
STCP=0;
STCP=1;
//select(X_table);
operate(Y_table);
OE=0;
i++;
if(i==16)
i=0;
select(X_table);
flag=0;
}
}
}
void timer0() interrupt 1
{
TH0=(65535-1000)/256;
TL0=(65535-1000)%256;
flag=1;
}file:///C:/Documents
关键是如何才能逐行滚动显示,不要那种一下跳出一个字的。 |