#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
delay_ms(unsigned
int
x)
{
unsigned
int
i,j;
if
(x==1000)
{
for
(i=0;i<19601;i++)
{
for
(j=5;j>0;j--);
}
}
else
while
(x--)
for
(j=115;j>0;j--);
}
void
main()
{
unsigned
char
key_up=1;
unsigned
char
i=1;
ADDR3 = 1;
ENLED = 0;
ADDR2 = 1;
ADDR1 = 1;
ADDR0 = 0;
P2 = 0xF7;
P0 = 0xFE;
while
(1)
{
if
(key_up==0)
{
if
(KEY4==1)
{
P0=~(0x01<<i);
i++;
if
(i>=8)i=0;
}
}
key_up=KEY4;
delay_ms(2);
}
}