I want to move three servos together at the same time. I want the action to be that when you flip a switch, the three servos together move from 0 degrees to 180, then when the switch is flipped again the servos all move back from 180 degrees to 0 degrees. I am using an arduino uno with a
SparkFun PWM Shield It will have a 12 volt - 3 amp supply connected to it, over kill but I LIKE THE POWER! I just need some help with this because so far from what I have seen, everyone else can only run one servo at a time. No multi-threading.
I have looked at using this Library for the code. It is the library related to the shield.
Thanks everyone!
EDIT:
Will connecting multiple servos to one PWM damage the arduino? Having separate VCCs for them though, so the only common pin between them would be the actual PWM pin to the board.
//zoomkat servo button test 7-30-2011
//Powering a servo from the arduino usually *DOES NOT WORK*.
#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;
void setup()
{
pinMode(button1, INPUT);
servo1.attach(7);
digitalWrite(4, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
servo1.write(160);
}
else {
servo1.write(20);
}
}
One way to do this is to move the servos in small increments - a degree at a time for example. Then, although they won't necessarily move at exactly the same time, it will appear that they are.