#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit wa=P2^6;
sbit wu=P2^7;
uchar num=40,x,y,t=0,l=45,h=80;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar code a[]={ 0x01,0x02,0x04};
void delay(int z)
{ for(x=z;z>0;z--)
for(y=110;y>0;y--);
}
void main()
{
TMOD=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{if(num<=40&&num>0)
{ wa=1;
wu=0;
P1=table[num%10];
delay(5);
wu=1 ;
wa=0;
P1=table[num/10];
delay(5);
P3=a[0];}
if(l<=5&&l>0)
{
wa=1;
wu=0;
P1=table[l%10];
delay(5);
wu=1 ;
wa=0;
P1=table[l/10];
delay(5);
P3=a[1];
}
if(h<=35&&h>0)
{
wa=1;
wu=0;
P1=table[h%10];
delay(5);
wu=1 ;
wa=0;
P1=table[h/10];
delay(5);
P3=a[2];
}
}
}
void time() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t++;
if(t==20)
{
t=0;
num--;
l--;
h--;
if(h==0)
num=40;
if(num==0)
l=5;
if(l==0)
h=35;
}
}