#include<reg52.h>
sbit a=P1^0;
sbit b=P1^1;
unsigned char code discode1[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};
unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
#define uchar unsigned char
uchar counter=0;
uchar key=0;
uchar second=0;
uchar minute=0;
main()
{
a=1;
b=0;
TMOD=0X01;
TH0=0xDc;
TL0=0x00;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if((P3&0x80)==0x00)
{
key++;
switch(key)
{
case 1:
P2=0x7f; //11111111
P0=discode2[second%10];
break;
case 2:
P2=0xbf; //10111111
P0=discode2[second/10];
break;
case 3:
P2=0xdf; //11011111
P0=discode2[minute%10];
break;
}
}
}
}
void zhongduan()interrupt 1
{
TH0=0xee;
TL0=0x00;
TF0=0;
TR0=1;
counter++;
if(counter==200)
{
counter=0;
second++;
if(second==60)
{
second=0;
minute++;
}
}
}
|