Seeking guidance on writing code for 3 servos activated by a push-button.

Afternoon all,

I am currently trying to write some code for a uni project and keep getting stuck straight after I think I've solved the problem.

My aim is to write code that will allow me to activate 3 servos after I've pressed a push button. The servos must be able to move 170 degrees and then back to 0, one after the other, and then stop after all 3 have completed the action.

I am trying to separate the action each servo must perform using millis(), but I am struggling to understand how to properly apply this to the code.

Any help, advice or examples would be extremely appreciated.

Kind regards to all.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Can you post the code you have been trying please.

Look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Please include power supplies.

Thanks.. Tom.. :slight_smile:

I think there's probably more to it than you have said. Otherwise you'd just need (pseudocode):
in setup()
if button has been pressed
servo1.write(170)
delay
servo1.write(0)
delay
servo2.write(170)
delay
etc.

I'm guessing its not quite that simple. Please provide a more detailed specification and show us your best attempt so far.

Steve