#include<reg52.h>
sbit weixuan=P2^6;
sbit duanxuan=P2^5;
unsigned char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char k=0,shi,ge,num=0;
int s;
void fun(unsigned char shi,unsigned char ge);
void delay(int s) ;
void main()
{int i=0;
unsigned int num=0;
TMOD=0x10;
TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
EA=1;ET1=1;TR1=1;
while(1)
{
fun(shi,ge);
}
}
void T1_time()interrupt 3
{TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
num++;
if(num==20)
{
num=0;k++;
}
shi=k/10;
ge=k%10;
}
void delay(s)
{int i,j;
for(i=s;i>0;i--)
for(j=110;j>0;j--);
}
void fun(unsigned char shi,unsigned char ge)
{duanxuan=1;
P0=table[shi];
duanxuan=0;
P0=0x00;
weixuan=1;
P0=0x01;
weixuan=0;
delay(3);
duanxuan=1;
P0=table[ge];
duanxuan=0;
P0=0x00;
weixuan=1;
P0=0x02;
weixuan=0;
delay(3);
}
sbit weixuan=P2^6;
sbit duanxuan=P2^5;
unsigned char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char k=0,shi,ge,num=0;
int s;
void fun(unsigned char shi,unsigned char ge);
void delay(int s) ;
void main()
{int i=0;
unsigned int num=0;
TMOD=0x10;
TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
EA=1;ET1=1;TR1=1;
while(1)
{
fun(shi,ge);
}
}
void T1_time()interrupt 3
{TH0=(65535-45872)/256;
TL0=(65535-45872)%256;
num++;
if(num==20)
{
num=0;k++;
}
shi=k/10;
ge=k%10;
}
void delay(s)
{int i,j;
for(i=s;i>0;i--)
for(j=110;j>0;j--);
}
void fun(unsigned char shi,unsigned char ge)
{duanxuan=1;
P0=table[shi];
duanxuan=0;
P0=0x00;
weixuan=1;
P0=0x01;
weixuan=0;
delay(3);
duanxuan=1;
P0=table[ge];
duanxuan=0;
P0=0x00;
weixuan=1;
P0=0x02;
weixuan=0;
delay(3);
}