So I have a bunch of functions (methods) made and I want to make it so that if the button is clicked (single click) the effects to change... I thought something like:
buttonState = digitalRead(buttonPin);
if(buttonState==HIGH) {
counter++;
if(counter>2) {
counter=0;
}
}
if(counter==0) {
Foo1();
}
if(counter==1) {
Foo2();
}
if(counter==2) {
Foo3();
}
But I noticed that it will only read the input button(buttonPin) if I click the button in the exact time (when the function has already ended and at digitalRead time)... So is there some way to do it even if the function is in progress to cancel it and go to the other ones (some way that the digitalRead will read it non stop)?
loop()
take less than that to run (worst case scenario), you will always catch the button. – user31481 Sep 7 '17 at 17:15