#include <reg51.H>
sbit P3_5 =P3^5;
unsigned char code dispcode[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0x00};
unsigned char second;
unsigned char keycnt;
unsigned int tcnt;
void main(void)
{
unsigned char i,j;
TMOD=0x02;
ET0=1;
EA=1;
second=0;
P1=dispcode[second/10];
P2=dispcode[second%10];
while(1)
{
if(P3_5==0)
{
for(i=20;i>0;i--)
for(j=248;j>0;j--);
if(P3_5==0)
{
keycnt++;
switch(keycnt)
{
case 1:
TH0=0x06;
TL0=0x06;
TR0=1;
break;
case 2:
TR0=0;
break;
case 3:
keycnt=0;
second=0;
P1=dispcode[second/10];
P2=dispcode[second%10];
break;
}
while(P3_5==0);
}
}
}
}
void t0(void) interrupt 1 using 0
{
tcnt++;
if(tcnt==4000)
{
tcnt=0;
second++;
if(second==100)
{
second=0;
}
P1=dispcode[second/10];
P2=dispcode[second%10];
}
}
免责声明:本平台仅供信息发布交流之途,请谨慎判断信息真伪。如遇虚假诈骗信息,请立即举报
举报