#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code f[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit wela=P1^1;
sbit dula=P1^0;
sbit jian=P2^4;
sbit jian2=P2^5;
uchar a=0,b=0,c;
uchar key_1(void);
uchar key_2(void);
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=150;y>0;y--);
}
void main()
{
uchar i;
while(1)
{
b=key_1();
a=key_2();
if(a>b) c=0x76;
if(a<b) c=0x38;
if(a==b) c=0x09;
for(i=0;i<50;i++)
{
dula=1;
P0=f[a];
dula=0;
P0=0xff;
wela=1;
P0=0xfd;
wela=0;
delay(5);
dula=1;
P0=f[b];
dula=0;
P0=0xff;
wela=1;
P0=0xfe;
wela=0;
delay(5);
dula=1;
P0=c;
dula=0;
P0=0xff;
wela=1;
P0=0xf7;
wela=0;
delay(5);
}
}
}
uchar key_1(void)
{
static uchar x;
if(jian==0)
{
delay(20);
if(jian==0)
{
x=x+1;
}
while(!jian);
}
if(x>9) x=0;
return x;
}
uchar key_2(void)
{
static uchar y;
if(jian2==0)
{
delay(20);
if(jian2==0)
{
y=y+1;
}
while(!jian2);
}
if(y>9) y=0;
return y;
}