1 把輸出語句放到時間標識內,
2 增加消隱處理。
3 更新的速度不能太快,一般在100Hz左右就可以了。
#include<reg52.h>
unsigned char lie[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
unsigned char hang[3][8]={0x00,0x18,0x24,0x24,0x24,0x24,0x18,0x00, //數字0
0x00,0x3c,0x20,0x38,0x04,0x24,0x38,0x00, //數字5
0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00}; //數字8
int a,i,j;
void main()
{
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
TR0=1;
while(1)
{
if(TF0==1)
{
P1=0xff;
P2=hang[j][i];
P1=lie[i];
i++;
if(i==8)
{
i=0;
}
TF0=0;
a++;
if(a==100)
{
a=0;
j++;
if(j==3)
{
j=0;
}
}
}
}
} |