#include
#define uchar unsigned char;
#define uint unsigned int;
uchar count;
uint disnum;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code tabledu[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
display(uchar,uchar,uchar);
delay(uchar);
void main()
{
EA=1;
ET1=1;
TMOD=0X10;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
while(1)
{
if(count==10)//控制显示速度
{
count=0;
if(disnum==1000)
disnum=0;
disnum++;
}
display(disnum/100,disnum%100/10,disnum%10 );
}
}
void time1() interrupt 3
{
TH1=(65536-50000)/256;//50ms
T1= (65536-50000)%256;//50ms
count++;
}
display(uchar bai,uchar shi,uchar ge)
{
P0=tabledu[bai];
dula=1;
dula=0;
P0=0xfe;
wela=1;
wela=0;
delay(10);
P0=tabledu[shi];
dula=1;
dula=0;
P0=0xfd;
wela=1;
wela=0;
delay(10);
P0=tabledu[ge];
dula=1;
dula=0;
P0=0xfb;
wela=1;
wela=0;
delay(10);
}
delay(uchar x)
{
uchar a,b;
for(a=x;a>0;a--)
for(b=200;b>0;b--);
} |