#include <reg51.h>
unsigned char weima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char duanma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
#define weixuan P1
#define duanxuan P0
void dingshiqi();
void delay(unsigned int i);
unsigned int time=0;
unsigned int m;
void main()
{
unsigned int i;
dingshiqi();
while(1)
{
if(time==5)
{
time=0;
m++;
if(m==99)
{
m=0;
}
weixuan=weima[0] ;
duanxuan=duanma[m/10];
delay(1000);
weixuan=weima[1];
duanxuan=duanma[m%10];
delay(1000);
}
}
}
void delay(unsigned char i)
{
while(i--) ;
}
void dingshiqi()
{
TMOD |=0x01;
TH0=0x3c;
TL0=0xb0;
EA=1;
ET0=1;
TR0=1;
}
void zhongduan() interrupt 1
{
TH0=0x3c;
TL0=0xb0;
time++;
}
unsigned char weima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char duanma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
#define weixuan P1
#define duanxuan P0
void dingshiqi();
void delay(unsigned int i);
unsigned int time=0;
unsigned int m;
void main()
{
unsigned int i;
dingshiqi();
while(1)
{
if(time==5)
{
time=0;
m++;
if(m==99)
{
m=0;
}
weixuan=weima[0] ;
duanxuan=duanma[m/10];
delay(1000);
weixuan=weima[1];
duanxuan=duanma[m%10];
delay(1000);
}
}
}
void delay(unsigned char i)
{
while(i--) ;
}
void dingshiqi()
{
TMOD |=0x01;
TH0=0x3c;
TL0=0xb0;
EA=1;
ET0=1;
TR0=1;
}
void zhongduan() interrupt 1
{
TH0=0x3c;
TL0=0xb0;
time++;
}
