I am attempting to use button counting to cycle through different options in my program, specifically how fast a strip of 7 NeoPixels cycle through a rainbow patern.
The issue I am running into is that the only time the change in state of the push button is being read is at the end of the function that cycles the rainbow. Meaning only a perfectly timed button press gets the counter to increment.
You could use interrupts to increase "counter" and Case statements instead of if(counter == 0), if(counter == 1). . .
Give it a try. And please format your code press CTRL + T or EDIT -> auto-format.
I know it's not a proper solution, but it is a quick and very dirty solution to a small piece of code. If it was any longer then yes, I would have told him to use IF statements instead of the FOR loops, and to take out the delay.
Well I am really just learning this stuff, when I come up with an idea I try to splice together all the little things I have learned from reading book after book and pages and pages of arduino sketches (however un-commented).
If there is a better way still I would like to hear it.
it is working pretty much how I want it to minus the fact that even after a button press it must finish what ever loop it is on before changing the speed.
again I am just trying to learn all of this, if there is a better way to do it I would love for some one to tell me about it.