各位大师,我最近在学数码管的动态显示,是用两位的数码管,首先想做一个简单的0到99秒的秒表,可是扫描的太快,是不是应该直接写个定时一秒的程序呢,应该怎么改,程序如下:
#include
#include
char code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};/*共阴数码管*/
unsigned char data led[]={0,0};/*用两个LED定义成一个数组,用来显示个位和十位*/
char code num1[]={0xfd,0xfe};
#define uint unsigned int
#define uchar unsigned char
uint count;
bit flag;
char tt;
void delay(uint x)
{
uchar i;
while(x--)
{
for(i=120;i>0;i--);
}
}
void show()
{
uint i;
led[1]=count/10;
led[0]=count%10;
if(led[1]>9)led[1]=led[1]-10;
if(led[1]==0)
{led[1]=0x0a;}
for(i=0;i<2;i++)
{
P0=num1;
P1=num[led];
delay(20);
}
}
int time0()interrupt 1/*不能用UINT*/
{
char time=0;
TH0=-100000/256;
TL0=-100000%256;
count++;
delay(20);
}
int main()
{
TMOD=0X01;
TH0=-100000/256;
TL0=-100000%256;
TR0=1;
EA=1;
ET0=1;
/* delay(100);*/
while(1)
{
show();
}
}