#include <reg51.h>
typedef unsigned int uint;
uint num;
uint num1;
uint num2;
char leds[16]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit LED=P2^0;
sbit kongwei1=P2^2;
sbit kongwei2=P2^3;
sbit kongwei3=P2^4;
static int shi;
static int ge;
void delay(int n)
{
while(n--);
}
void dongShu(){
uint i;
for(i=0;i<2;i++){
if(i==0){
kongwei1=0;
kongwei2=1;
kongwei3=1;
P0=leds[ge];
}else if(i==1){
kongwei1=1;
kongwei2=1;
kongwei3=1;
P0=leds[shi];
}
delay(100);
P0=0x00;
}
}
void timerInit(){
EA=1;
TMOD=0x11;
ET0=1;
TR0=1;
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
ET1=1;
TR1=1;
TH1 = (65536-45872)/256;
TL1 = (65536-45872)%256;
}
void timer1() interrupt 3{
TH1 = (65536-45872)/256;
TL1 = (65536-45872)%256;
num1++;
if(num1==20){
num1=0;
num++;
shi=num/10;
ge=num%10;
if(num==100){
num=0;
}
}
}
void timer0() interrupt 3{
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
num2++;
if(num2==20){
num2=0;
LED=~LED;
}
}
void main () {
timerInit();
while(1){
dongShu();
}
}