@@paulmcwhorter Tickled my brain! I finally solved this problem with a while loop in the if statement. if (buttonVal == 0 & ledVal == 0){ while (buttonVal == 0) { buttonVal = digitalRead(buttonPin); } digitalWrite(ledPin, HIGH); } and a similar block of code to turn the light off. Interested to see how you solve this problem!
Now test your solution by varying how quickly you push the button. Try long and short button pushes.
Ok will do!! Should the program always work regardless of the amount of time the button is pressed?
@@shineeyman Yes. Your user might have quick or slow fingers. The problem just got harder for you.
@@paulmcwhorter Tickled my brain!
I finally solved this problem with a while loop in the if statement.
if (buttonVal == 0 & ledVal == 0){
while (buttonVal == 0) {
buttonVal = digitalRead(buttonPin);
}
digitalWrite(ledPin, HIGH);
}
and a similar block of code to turn the light off. Interested to see how you solve this problem!