#include
#define uint unsigned int
#define uchar unsigned char
uchar code deng[]={0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}
uchar code shuma[]={0x90,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80}
uchar aa,bb,cc,num;
uint tz;
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=123;j>0;j--);
}
uchar keyscan()
{
uchar h,k,l;
P3=0xf0;
h=P3&0xf0;
if(h!=0xf0)
{
delay(5);
h=P3&0xf0;
P3=0x0f;
l=P3&0x0f;
while(P3!=0x0f);
switch(h+l)
{
case 0x77:k=1;break;
case 0x7b:k=2;break;
case 0x7d:k=3;break;
case 0xb7:k=4;break;
case 0xbb:k=5;break;
case 0xbd:k=6;break;
case 0xd7:k=7;break;
case 0xdb:k=8;break;
case 0xdd:k=9;break;
case 0x7e:k=11;break;
case 0xbe:k=12;break;
case 0xde:k=13;break;
}
return k;
}
else return 0xff;
}
if(k=9)
{
bb==1;
P0=P1=0x00;
}
if(bb==0)
{
if(aa==0)
{
if(k<10)
{
P0=shuma[k]
tz=k;aa==1;
}
}
if(aa==1)
{
if(k>10)
{
if(k==12)
{
P1=deng[tz]
}
if(k==13)
{
P0=P1=0x00;P3=0xff;
}
if(k=11)
{
P0=P1=0x00;P3=0xfd;cc==1;
}
}
if(cc==1)
{
if(P3=0xff)
{
void TO_time()interrupt 1
{
THO=(65536-50000)/256;
TLO=(65536-50000)%256;
num++;
if(num==60)
{
P0=0xc0;P1=P3=0xff;
}
}
}
}
void main()
{
display();
TMOD=0x01;
THO=(65536-50000)/256;
TLO=(65536-50000)%256;
EA=1;
ETO=1;
TRO=1;
while(1)
{
TMOD=0x01;
THO=(65536-50000)/256;
TLO=(65536-50000)%256;
EA=1;
ETO=1;
TRO=1;
}
}
0
|