Go Down

Topic: push button servo help (Read 1 time) previous topic - next topic


i need some help please. i'm trying to control a single servo to sweep into a position with a push button and make it return back to the original position with a push of the same button. if using the same button is impossible i don't mind adding a second one in. i've take a few programing classes and understand how to read the coding but have a hard time creating them. any kind of help will be greatly appreciated. thanks


Read the state of the button using digitalRead(). Count how many times the button has been pressed. If it's an odd number, sweep one way. If it's an even number, sweep the other way.

If that seems too difficult, keep track of where you last sent the servo to. If that value is 180, sweep in a negative direction. If that value was 0, sweep in a positive direction.

Go Up