#include <reg51.h>
#define uchar unsigned char
sbit key1=P2^0;
uchar code Table[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar num1, i,j,num,ge,shi,shi1,ge1,num2,num3;
void delay()
{
uchar i,j;
for(i=5;i>0;i--)
for(j=110;j>0;j--);
}
void T0_time() interrupt 1
{
TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
num1++;
num2++;
if(num1==20)
{
num1=0;
num2--;
num--;
if(num==0)
num=50;
shi=num/10;
ge=num%10;
}
if(num2==20)
{
num2=0;
num3--;
if(num3==0)
num3=20;
shi1=num3/10;
ge1=num3%10;
}
}
void display(uchar ge,uchar shi,uchar ge1,uchar shi1)
{
P2=0Xfd;
P0=Table[ge]; delay();
P2=0xfe;
P0=Table[shi]; delay();
P2=0Xfb;
P0=Table[ge1]; delay();
P2=0xf7;
P0=Table[shi1]; delay();
}
void main()
{
TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
EA=1;
ET0=1;
TR0=1;
num=50;
num3=20;
num1=0;
while(1)
{
display(ge,shi,ge1,shi1);
}
}
|