Loading...
Pages: [1]   Go Down
Author Topic: Using Multiple Servos with Arduino  (Read 927 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, I have 8 servos that I want to drive with my Arduino. I know I shouldn't connect all the servos to the GND and +5v of Arduino. Somebody told me that servos when working pull about 2 amps each Is this correct? How should I hook an external battery with Arduino to my servos? I am told that I can hook up DC jack into Arduino, an external batteries GND to Arduino's GND, and the external batteries + to +5v on Arduino. Is this correct? Please help me out here.
Logged

Johannesburg UTC+2
Offline Offline
Edison Member
*
Karma: 34
Posts: 1705
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep that's right. Have a look at my pic below, and go and read DuaneB's work, starting here. He has some test results for current draw.
Logged

IT Crowd:
Roy... "Have you tried turning it off and on again?"
Moss.. "Have you tried forcing an unexpected reboot?"

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6532
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Basic servo setup.

Logged

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

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

Thanks Zimbo for the tremendous help. I'm enjoying the website you linked to your post, it's very helpful. What I'm making is a 4 legged spider! (I really hope it works smiley
Zoomkat, makes perfect sense. Thank you as well.
Logged

Johannesburg UTC+2
Offline Offline
Edison Member
*
Karma: 34
Posts: 1705
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thanks Zimbo

That's Jimbo  smiley-cool, but you're welcome all the same.

Yep DuaneB seems to be the go-to-guy for servo know-how.

[zen]Is a 4-legged spider really a spider?[/zen]
Logged

IT Crowd:
Roy... "Have you tried turning it off and on again?"
Moss.. "Have you tried forcing an unexpected reboot?"

yogyakarta
Offline Offline
Newbie
*
Karma: 0
Posts: 1
learning by expostulating
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh it's so help me actually. Now, I use 5 servos in my project. Can anybody help me for give a little sketch ?  I am so confuse to start it.  smiley-roll-sweat
Logged

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6532
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh it's so help me actually. Now, I use 5 servos in my project. Can anybody help me for give a little sketch ?  I am so confuse to start it.  smiley-roll-sweat

Several servo control code.

Code:
//zoomkat 11-22-12 simple delimited ',' string parse
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added

String readString;
#include <Servo.h>
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded
}

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or combined like 30c,180b,70a,120d,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
        {
          Serial.print("writing Microseconds: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
        }
        else
        {   
          Serial.print("writing Angle: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
        }
         readString=""; //clears variable for new input
      }
    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}

Logged

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Pages: [1]   Go Up
Print
 
Jump to: