Connecting multiple servo’s to Arduino

Imagine the task when you need to make a manipulator arm or spider robot. In this case, we will need to control several servo motors.
image1_9ad5b448-180e-48ca-81de-be1e0e5acdfd

Imagine the task when you need to make a manipulator arm or spider robot. In this case, we will need to control several servo motors.

You will need:

  • Arduino board (Uno, Mega, Nano, …)
  • 3x Servo
  • Breadboard 
  • Wires

Servos are connected to individual PWM pins.

I added an electrolytic capacitor parallel to the power line to my assembly.

The whole point of controlling several servo machines is that we create one object for each servo motor. The servo class contains all the necessary methods to operate the servo.

//connecting servo library

#include

//create servos

Servo servo1;

Servo servo2;

Servo servo3;

void setup() {

 //attach servo pins

 servo1.attach(9);

 servo2.attach(10);

 servo3.attach(11);

}

void loop() {

 //turn all left

 servo1.write(0);

 servo2.write(0);

 servo3.write(0);

 //wait

 delay(500);

 //turn all right

 servo1.write(180);

 servo2.write(180);

 servo3.write(180);

 //wait

 delay(500);

}

Demonstration.

As you can see, managing individual servos is quite a simple task. You can try to connect them, and you get a “caterpillar”, which is much more difficult to control.

In the next lesson, we will look at the assembly of a two-link manipulator and learn how to control it.

Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest