sbit LED1=P2^0
sbit LED2=P2^1
sbit LED3=P2^2
sbit LED4=P2^3
sbit P3_5 =P3^5
unsigned char keycnt
unsigned char Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}
unsigned int counet,second,msecond,minute
void delay(unsigned int m)
{
unsigned char s
for(m>0m--)
for(s=124s>0s--)
}
void display()
{
P0=Tab[msecond%10]
LED4=1
delay(5)
LED4=0
P0=Tab[second%10]+0x80
LED3=1
delay(5)
LED3=0
P0=Tab[second/10]
LED2=1
delay(5)
LED2=0
P0=Tab[minute%10]
LED1=1
delay(5)
LED1=0
}
main()
{
unsigned char i,j
P0=0xff
P1=0xff
TMOD=0x01
// TH0=0x3c
// TL0=0xb0
EA=1
ET0=1
// TR0=1
while(1)
{
display()
if(P3_5==0)
{
for(i=20i>0i--)
for(j=248j>0j--)
if(P3_5==0)
{
keycnt++
switch(keycnt)
{
case 1:
TH0=0x3c
TL0=0xb0
TR0=1
break
case 2:
TR0=0
break
case 3:
second=0
msecond=0
minute=0
keycnt=0
break
}
while(P3_5==0)
}
}
}
}
void time0() interrupt 1
{
TH0=0x3c
TL0=0xb0
counet++
if(counet==2)
{
counet=0
msecond++
if(msecond==10)
{
msecond=0
second++
if(second==60)
{
second=0
minute++
if(minute==10)
{
minute=0
}
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)