#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar times,g,s,b,q;
uint num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uint c;
void delay(uint z)
{
while(z--);
}
void counter() interrupt 1
{
times++;
}
void LED_duan(uint c)
{
q=c/1000;
b=(c%1000)/100;
s=(c%100)/10;
g=c%10;
}
void LED_xianshi(uchar q,uchar b,uchar s,uchar g)
{
P2=0X01;
P1=num[g];delay(360);
P2=0X02;
P1=num[s];delay(360);
P2=0X04;
P1=num[b];delay(360);
P2=0X08;
P1=num[q];delay(360);
}
void main()
{
TMOD=0X06;
TH0=0;
TL0=0;
EA=1;
ET0=1;
TR0=1;
times=0;
while(1)
{
c=times*256+TL0;
if(c<=9999)
{
LED_duan(c);
LED_xianshi(g,s,b,q);
}
else
{
times=0;
TL0=0;
}
}
}
#define uint unsigned int
#define uchar unsigned char
uchar times,g,s,b,q;
uint num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uint c;
void delay(uint z)
{
while(z--);
}
void counter() interrupt 1
{
times++;
}
void LED_duan(uint c)
{
q=c/1000;
b=(c%1000)/100;
s=(c%100)/10;
g=c%10;
}
void LED_xianshi(uchar q,uchar b,uchar s,uchar g)
{
P2=0X01;
P1=num[g];delay(360);
P2=0X02;
P1=num[s];delay(360);
P2=0X04;
P1=num[b];delay(360);
P2=0X08;
P1=num[q];delay(360);
}
void main()
{
TMOD=0X06;
TH0=0;
TL0=0;
EA=1;
ET0=1;
TR0=1;
times=0;
while(1)
{
c=times*256+TL0;
if(c<=9999)
{
LED_duan(c);
LED_xianshi(g,s,b,q);
}
else
{
times=0;
TL0=0;
}
}
}