#include <REGX51.H>
#define uchar unsigned char
#define uint unsigned int
uchar n=0,temp=0;
uchar code segcode0[]={0x5b,0x06,0x3f,0x5b,0x06,0x3f,0x5b,0x06,0x3f};
uchar code segcode1[]={0x6f,0x7f,0x07,0x7d,0x6d,0x66,0x4f,0x5b,0x06,0x3f};
//uchar code segcode0[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(x)
{ while(x--);
}
void timer0() interrupt 1
{ TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
n++;
temp=temp%61;
if(n==20)
{ temp++;
n=0;
}
if(temp<25) P1=0x21;
if((temp>=25)&&(temp<28)) P1=0x22;
if((temp>=28)&&(temp<30)) P1=0x24;
if((temp>=30)&&(temp<55)) P1=0x0c;
if((temp>=55)&&(temp<58)) P1=0x14;
if((temp>=58)&&(temp<60)) P1=0x24;
}
main()
{ uint i=0;
//P1_0=0;
//P1_7=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
//while(1)
//{//i=temp;
// }
// TH1=256-125;
// TL1=256-125;
EA=1;
ET0=1;
// ET1=1;
TR0=1;
while(1)
{
P2_0=0;
P2_1=1;
P0=segcode0[temp/10];
delay(3000);
P2_0=1;
P2_1=0;
P0=segcode1[temp%10];
delay(3000);
P2_1=1;//TR1=1;
}
}