用51单片机控制8*8点阵显示I love u 流动显示,在不断的调试中终于有个大概的雏形,但是还有一点问题就是显示的时候没有消隐,总是感觉不好。希望大家帮我看看程序,以及给点改进的建议,大家一起学习!谢谢。
程序如下:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uint counter=0,i=0;
uint j;
uchar code table4[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code table8[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //取模软件取的代码
0x00,0x00,0x42,0x7E,0x7E,0x42,0x00,0x00, // I
0x1C,0x3E,0x7E,0xFC,0xFC,0x7E,0x3E,0x1C,0x00,0x00,// love (最后2个0x00,在显示的时候隔开 love u)
0x00,0x3E,0x7E,0x40,0x40,0x7E,0x3E,0x00, // U
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
//*********函数声明*****
void init();
void delay(del);
//*******主函数*********
void main()
{
init();
while(1)
{ if(counter==10)
{
counter=0;
i++;
if(i==35)i=0;
}
for(j=0;j<8;j++)
{
P2=table4[j];//P0接点阵的阳极,P2接点阵的阴极
P0=table8[i+j];
delay(200);
}
}
}
//**********初始化函数*******
void init()
{
TMOD = 0x01; //工作于定时器0的方式1
TH0 = (65536-20000)/256; //定时20ms
TL0 = (65536-20000)%256;
EA = 1; //开总中断
TR0 = 1;
ET0 = 1;
}
void time1() interrupt 1
{
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
counter++;
}
//**********延时函数*******
void delay(del)
{
while(del--);
}