#include<reg51.h>
void delay(unsigned int i)
{
unsigned char j,k;
for(j=0;j<i;j++)
for(k=0;k<255;k++);
}
void main()
{
unsigned int h,l;
P2=0X00;
P3=0X00;
while(1)
{
P1=0XF0;
h=P1;
if(h!=0xf0)
{
delay(1000);
h=P1;
if(h!=0xf0)
{
h=h&0xf0; /*1110 0000*/
P1=0X0F; /*11101111*/
delay(1);
l=P1;
l=P1;
if(l!=0x0f)
{
delay(1000);
if(l!=0x0f)
{
l=l&0x0f;
h=h+l;
}
}
}
}
if(h==0x11)
{
P2=0XC0;
P3=0XFF;
delay(255);
}
}
}
-
一周热门 更多>