#include <reg52.h>
sbit ADDR2 = P1^2;
sbit ADDR1 = P1^1;
sbit ADDR0 = P1^0;
sbit ENLED = P1^4;
sbit ADDR3 = P1^3;
unsigned
char
code LedChar[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
unsigned
char
LedBuff[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
void
main()
{
unsigned
int
i=0,x;
unsigned
char
Second=0,Minute=0;
ADDR3 = 1;
ENLED = 0;
while
(1)
{
LedBuff[0]=LedChar[Second%10];
LedBuff[1]=LedChar[(Second/10)%10];
LedBuff[2]=0x7F & LedChar[Minute%10];
if
(Minute>=10)LedBuff[3]=LedChar[(Minute/10)%10];
if
(Minute==0)LedBuff[3]=0xFF;
for
(x=0;x<29480;x++)
{
P0=0xFF;
switch
(i)
{
case
0:
ADDR2 = 0;ADDR1 = 0;ADDR0 = 0;P0=LedBuff[0];i++;
break
;
case
1:
ADDR2 = 0;ADDR1 = 0;ADDR0 = 1;P0=LedBuff[1];i++;
break
;
case
2:
ADDR2 = 0;ADDR1 = 1;ADDR0 = 0;P0=LedBuff[2];i++;
break
;
case
3:
ADDR2 = 0;ADDR1 = 1;ADDR0 = 1;P0=LedBuff[3];i=0;
break
;
}
}
Second++;
if
(Second>=60){Second=0;Minute++;}
if
(Minute>=60)Minute=0;
}
}