Go Down

Topic: Two Buttons, Two Inputs (Read 42304 times) previous topic - next topic

elwing

your code should "work" but it is quite wrong from a logic state, basically when only button 1 is pressed, your led will not stay on for the whole time, it will blink at a quite high frequency. that frequency is high enough for you not to notice, through you should be able to see a lower light in this case... it will probably produce major problem if you trigger action rather than powering a led...

this code should work quite better...
Code: [Select]

void loop(){
if(button1.isPressed()||button2.isPressed()){
    digitalWrite(13,HIGH);
}else{
    digitalWrite(13,LOW);
}
}

Go Up