loading

arduino button question?

Hey guys I have an arduino question.
I want to run both servo sweep and servo knob at the same time But be controlled by a button. 
Like servo swep starts up, i mash a button, then servo knob comes on and i can manually control the servo.
then push a button (either the same or another) and servo sweep comes back.
This is for arduino uno r3.

Please advise


Use a variable to track the number of times the button has been pressed. You void loop will consist of checking if the button has been pressed or not. It will also check the state of the tracking variable. If the tracking variable equals 1 than it will send you down to a void that contains the code needed to sweep the serveo. If it equals 2 than it goes to a void where you use a pot to control the servo.

thematthatter (author)  mpilchfamily3 years ago

do you have an example of multiple void loops? i think i almost got it figured out its just not doing exactly what i want.

Check out my arduino simon says game or total recall game.

https://www.instructables.com/id/Arduino-Simon-Says...

https://www.instructables.com/id/Total-Recall-Ardui...

In the Arduino Simon Says code you will see towards the end of the void loop(0 it has the command input() which directs the code to the void input(). WHen the code is done with the void input() section it will return to the void loop() again. Unless of course it sees the user has failed. It will then send the code to the void fail() section which tells teh user they lost and restarts the game.