#include <REGX52.H>
sbit Key1=P2^0;
sbit Key2=P2^1;
sbit Key3=P2^2;
sbit Key4=P2^3;
void Delayms(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
{
for(j=0;j<120;j++);
}
}
void main()
{
while(1)
{
if(P2&0x0f!=0x0f)
{
Delayms(10);
if(P2&0x0f!=0x0f)
{
if(Key1==0)
{
P1=0xfe;//1111 1110
}
else if(Key2==0)
{
P1=0xfd;//1111 1101
}
else if(Key3==0)
{
P1=0xfb;//1111 1011
}
else
{
P1=0xf7;//1111 0111
}
}
}
else
{
P1=0xff;
}
}
}