#include <reg52.h>
sbit ADDR2 = P1^2;
sbit ADDR1 = P1^1;
sbit ADDR0 = P1^0;
sbit ENLED = P1^4;
sbit ADDR3 = P1^3;
sbit LED2 = P0^0;
sbit KEY4 = P2^7;
void
main()
{
unsigned
char
key_up=1;
unsigned
char
i=0;
unsigned
int
times=0;
unsigned
int
x;
ADDR3 = 1;
ENLED = 0;
ADDR2 = 1;
ADDR1 = 1;
ADDR0 = 0;
P2 = 0xF7;
while
(1)
{
if
(key_up==0)
{
times++;
if
(times>=1000&&KEY4==1)
{
times=0;
LED2=!LED2;
}
}
key_up=KEY4;
x++;
if
(x>=3000)
{
x=0;
P0=~(0x04<<i)&(0xFE|LED2);
i++;
if
(i>=6)i=0;
}
}
}