#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};
void
main()
{
unsigned
int
i,x;
unsigned
char
sec;
ADDR3 = 1;
ENLED = 0;
P0=0xC0;
while
(1)
{
for
(x=0;x<28492;x++)
{
switch
(i)
{
case
0: ADDR2 = 0;ADDR1 = 0;ADDR0 = 0;i++;
break
;
case
1: ADDR2 = 0;ADDR1 = 0;ADDR0 = 1;i++;
break
;
case
2: ADDR2 = 0;ADDR1 = 1;ADDR0 = 0;i++;
break
;
case
3: ADDR2 = 0;ADDR1 = 1;ADDR0 = 1;i++;
break
;
case
4: ADDR2 = 1;ADDR1 = 0;ADDR0 = 0;i++;
break
;
case
5: ADDR2 = 1;ADDR1 = 0;ADDR0 = 1;i=0;
break
;
}
}
sec++;
if
(sec>=16)sec=0;
P0=LedChar[sec];
}
}