#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()
{
ADDR3 = 1;
ENLED = 0;
ADDR2 = 1;
ADDR1 = 1;
ADDR0 = 0;
P2 = 0xF7;
while
(1)
{
if
(KEY4==0)
{
delay_ms(50);
if
(KEY4==0)
{
LED2=!LED2;
}
}
}
}