Hi,
Total newbie here. I'm trying to expand on one of the projects that came with the Arduino starter kit but I've ran into a bit of an error.
I'm trying to basically flash two lights when the button is pressed and stop the flashing when another button is pressed. To make the lights flash, you don't have to hold down the button because I'm using a while loop.
However, when I try to check if the other button was pressed, and if so break, at the end of my while loop, nothing seems to occur. I can guarantee that my circuit is correct because if I try doing something else with that button, it works fine. Hopefully my code will make more sense and someone can help me find the error. Why is it not stopping the flashing if the other button was pressed? Attached is my code.
Thank you!
void loop() {
goodSwitchCounter = digitalRead(3);
badSwitchCounter = digitalRead(7);
if (badSwitchCounter == HIGH){
while (goodSwitchCounter != HIGH){
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(250);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
delay(250);
}
}
else{
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
}