给你一个程序吧P1口接LED灯P3口接ABCD下面有对应引脚
//当按下无线遥控器的A-B-C-D键时,流水灯D1-D2-D3-D4对应亮起.松手熄灭。
#include
sbitkey1=P3^4;
sbitkey2=P3^5;
sbitkey3=P3^6;
sbitkey4=P3^7;
sbitlinght1=P1^3;
sbitlinght2=P1^2;
sbitlinght3=P1^1;
sbitlinght4=P1^0;
voidmain()
{
while(1)
{
if(key1==1)
linght1=0;
else
linght1=1;
if(key2==1)
linght2=0;
else
linght2=1;
if(key3==1)
linght3=0;
else
linght3=1;
if(key4==1)
linght4=0;
else
linght4=1;
}
}