51proteus仿真:按键控制led灯

mac2022-06-30  86

51proteus仿真:按键控制led灯

 

按键按下,led等亮。否则,led灯灭。

仿真电路图:

仿真程序如下:

 

#include <reg52.h>#define uchar unsigned char sbit LED=P3^0; sbit KEY=P1^0;void delay(){uchar j,k; for(j=0;j<200;j++)  for(k=0;k<200;k++)k=k;

}main(){ uchar i;while(1){

i=KEY;if(i==0){ delay();

i=KEY;

 if(i==0)LED=0;

} else{ delay();

i=KEY;

 if(i==1)LED=1;

}

}

 

}

 

转载于:https://www.cnblogs.com/proteus/archive/2011/10/27/2227097.html

相关资源:ARM7 按键控制流水灯
最新回复(0)