缘由51单片机:两个独立按键控制一个led,k1按下松开led闪烁三次,k2按下LED闪烁五次_嵌入式-CSDN问答
cpp
#include "REG52.h"
sbit K1 = P1^0;
sbit K2 = P1^1;
sbit LED=P0^0;
void main()
{
unsigned char Xd=0,ss=0;
unsigned int wei=0;
while(1)
{
if(K1==0&&++Xd==0){ss=3*2;while(K1==0);}
if(K2==0&&++Xd==0){ss=5*2;while(K2==0);}
if(ss&&!++wei)
{
LED=~LED;
--ss;
}
}
}