I'm learning to use Arduino and need to use a button to sweep a servo to 4 locations at different speeds.
I think this can be done using clicks since and if statement will only give me an else meaning two positions but i'm not sure how to apply the clicks to the code.
looking at the sweep example i understand the pos is the position so i need to change that per click "for (pos = 180; pos >= 0; pos += 1) ", right?
Do you really mean one servo doing 4 different things at different times?
If by "clicks" you mean multiple button presses then the problem is that you have to wait for some defined amount of time after the first press to see if there is going to be a second press and then wait to see if there is a third press etc. It makes the response quite slow. Is that what you're aiming for?
When you get that sorted out the rest is simple. In Sweep, as you say the position is governed by pos. The speed of movement is controlled by the value in the delay(15) statement. Larger number, slower move etc.