push a button to begin and continuously run a loop.
What I have:
I push a button and the loop runs once.
What I've programmed:
I'm using an if statement to say if I push the button, run the loop. Of course, since the loop begins with the "if the button is pushed" requirement I have to push the button each time to initiate the loop. I've tried moving the if statement out of the loop, but then the loop just runs regardless of whether or not I push the button.
Use the state change detection method to sense when the button becomes pressed and set a flag. Then if the flag is set run the loop. If the button becomes pressed again, clear the flag to stop the loop.
I guess button wasn't quite the right term, perhaps tactile switch is more accurate like this one:
I am trying to have nothing happen until I push the tactile switch. Once pressed, I would like the code to run in a loop until the sun burns out. Or I push a second tactile switch. Whichever happens first.