刚接触,求大神指导一下现在按下PB8,PC13会输出高电平了
如何按一下PB8,PC13会一直输出高电平呢?
我还想增加一个PB7,按一下PB7,PC13会输出低电平
实现按一下PB8灯亮,按一下PB7灯灭
int KEY = PB8;
int iLed = PC13;
void setup()
{
pinMode(PB8, INPUT);
pinMode(iLed, OUTPUT);
}
void loop() {
digitalWrite(PC13,LOW);
if(digitalRead(PB8)==LOW) {
delay(100);
if(digitalRead(PB8)==LOW) {
digitalWrite(PC13,HIGH);
while(digitalRead(PB8)==LOW) {
}
}
}
}
|