# define uchar unsigned char
# define uint unsigned int
Sbit LED0 P1=^ 0;
P1 sbit LED1=^ 1;
Sbit LED2=p ^ 2;
Sbit LED3 P1=^ 3;
Sbit d1=P0 ^ 0;
Sbit d2=P0 ^ 1;
Sbit d3=P0 ^ 2;
Sbit d4=P0 ^ 3;
Sbit Btton=P3 ^ 2;
Char timedao1;
Char timedao2;
Code unsigned char table []=
X5b x06 x3f {0, 0, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x00};
/* * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * */
Void delayms (XMS)
{
Uint I, j;
For (I=XMS; I> 0; I -)
For (j=110; J> 0; J -);
}
Void the Display ()
{
Char h, l;
H=timedao1/10;
L=timedao1%10;
D1=1;
D2=0;
D3=1;
D4=1;
The P2=table [h];
The P2=table [l];
Delayms (10);
D2=1;
D1=0;
H=timedao2/10;
L=timedao2%10;
The P2=table [h];
Delayms (2);
D3=1;
D4=1;
The P2=table [h];
Delayms (2);
D4=1;
}
Void timer0 (void) interrupt using 1
{
The static uchar count;
TH0=(65536-50000)/256;
TL0=(65536-50000) % 256;
count++;
If (count==20)
{
If (timedao1>=0)
Timedao1 -;
If (timedao2>=0)
Timedao2 -;
Count=0;
}
}
Void main ()
{
Int c;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000) % 256;
EA=1;
ET0=1;
EX0=1;
IT0=1;
TR0=1;
While (1)
{
Timedao1=9;
Timedao2=4;
While (timedao1>=0)
{
LED3=0;
LED0=0;
The Display ();
}
For (c=0; C <11; C + +)
{
LED3=~ LED3;
LED0=~ LED0;
Delayms (1000);
}
Timedao1=9;
Timedao2=4;
While (timedao1>=0)
{
LED2=0;
LED1=0;
The Display ();
}
For (c=0; C <11; C + +)
{
LED1=~ LED1;
LED2=~ LED2;
Delayms (1000);
}
}
}