Hello,
I am using a while loop to do something to keep things simple I cut the code and used the led blink.
The loop breaks when you hold the push button the whole time (the worst case here is 10 seconds).
Is there a way to break the loop instantly as soon the button is pushed without completing the whole code in the while loop?
buttonState = digitalRead(4);
while(buttonState == HIGH)
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(5000);
}
}