i want to control 5 servos with an arduino uno.the way i want to have the motors controlled is if i hit enter on my computer then i want it to start sending codes to arduino to control the servos.so my question is does anyone have a code for 5 servos and how do i connect the servos to arduino.
i want to control 5 servos with an arduino uno.the way i want to have the motors controlled is if i hit enter on my computer then i want it to start sending codes to arduino to control the servos.so my question is does anyone have a code for 5 servos and how do i connect the servos to arduino.
Well before you tackle how to control five servos, first you should come up with a plan on how you will be powering the 5 servos. An arduino board cannot power that many servos but will have no problem controlling all of them.
i want to control 5 servos with an arduino uno.the way i want to have the motors controlled is if i hit enter on my computer then i want it to start sending codes to arduino to control the servos.so my question is does anyone have a code for 5 servos and how do i connect the servos to arduino.
Well before you tackle how to control five servos, first you should come up with a plan on how you will be powering the 5 servos. An arduino board cannot power that many servos but will have no problem controlling all of them.
Lefty
basically i will be using some batteries and a regulator to power the servos
To have 5 servos (or should that be servoes? or servi? ) just repeat the Servo myservo; line with lines like Servo myservo3; etc and then have lines like myservo3.attach and myservo3.write.
Then have a look at the code below which shows how to read characters from your pc and act on what was keyed in. In this case I used the "h" and "H" to control an LED but that could be adapted to send writes to a particular servo. (It also echoes the received code back to the monitor so you can see it's reading the keystrokes correctly.)
char incomingByte; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte);
}
if (incomingByte == 'h' || incomingByte == 'H')
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
}
Thanks for the post.... it's given me some ideas for some servo stuff I want to do...