Pages: [1]   Go Down
Author Topic: controlling 5 servos  (Read 659 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi everyone,

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16464
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi everyone,

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
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8894
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You will need to find or write an application that can take keyboard keystrokes and send servo commands based on the keystrokes to the arduino.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi everyone,

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
Logged

Johannesburg UTC+2
Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well here's some stuff which might start you off....

First have a look at this: http://arduino.cc/en/Tutorial/Sweep if you didn't already.

To have 5 servos (or should that be servoes? or servi? smiley ) 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.)

Code:
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...
« Last Edit: December 06, 2012, 12:09:56 am by JimboZA » Logged

Have you looked for answers in the Learning, Reference, Products and Playground tabs on http://arduino.cc/en/ ?
Look here http://electronicsclub.info/ for basic electronics

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16464
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
basically i will be using some batteries and a regulator to power the servos

And what current rating for the regulator is planned? A single 7805 type will not be enough for 5 servos.

Lefty
Logged

Pages: [1]   Go Up
Jump to: