You are on page 1of 10

ARDUINO (HTTPS://CIRCUITDIGEST.COM/ARDUINO-PROJECTS)

Controlling Multiple Servo Motors with


Arduino (/microcontroller-
projects/controlling-multiple-servo- CR01005 Series Thick-Film
Chip Resistor

motors-with-arduino) (https://bit.ly/34JX0QT )
The CR01005 chip resistor
By (page_author.html)Pankaj Khatri (/users/pankaj-khatri) Apr 23, 2018 5 features a three-layer termination
(https://bit.ly/34JX0QT
process with a nickel barrier
)
SRP0310 /
SRP0315/SRP0410 /
SRP0510 / SRP0610 Series
Shielded Power Inductors
(https://bit.ly/31ZvmxA )
(https://bit.ly/31ZvmxA
SRP0310/0315/0410/0510/0610
) shielded power inductors have a
metal alloy powder core and flat wire

TBU-RS Dual Channel TBU®


High-Speed Protector Series
(https://bit.ly/3mIptNl )
The TBU-RS055-300-WH is an
integrated dual-channel TBU
(https://bit.ly/3mIptNl
overcurrent and TVS overvoltage
) protector

AEC-Q200 Compliant Thick


Film Chip Resistors - Model
CRxxxxA Series
(https://bit.ly/34LdiZG )
The model CRxxxxA AEC-Q200
(https://bit.ly/34LdiZG
compliant chip resistor series is
) available in eight different
footprints

AVHT Series High-


Temperature Varistors
(https://bit.ly/3gFrqb5 )
AVHT high-temperature varistors
offer great circuit-board layout
(https://bit.ly/3gFrqb5
flexibility for designers
)
Controlling Multiple Servo Motors with Arduino
Model SF-0603HIA-M/SF-
1206HIA-M Series SMD Fuse
Using one or two Servo with Arduino (https://circuitdigest.com/microcontroller- Families
(https://bit.ly/3jGGdCJ )
projects/arduino-servo-motor-control-code-and-circuit) is Easy but what if we want to use
The Model SF-0603HIA-M/SF-
(https://bit.ly/3jGGdCJ
more than one Servo Motors? 1206HIA-M series utilize Bourns'
) popular multilayer ceramic design

SRP4018FA Series Power


Inductors
(https://bit.ly/3jMmLEm )
SRP4018FA shielded power
inductors are designed to meet
high current density requirements

(https://bit.ly/3jMmLEm
)
Chip LAN Transformer
Module - Model SM41126EL
Series
(https://bit.ly/3kJw7lG )
The SM41126EL Chip LAN
(https://bit.ly/3kJw7lG
10/100 Base-T transformer
) module is ideal for use in LAN
Here, we are going to show you that how to control Multiple Servo Motors with Arduino. interfaces

Connecting multiple Servo Motors with Arduino seems to be easy and but if we connect
all the Servos to Arduino supply pins then they won’t work correctly because of lack of
enough current to drive all the motors. So you have to use separate power supply for the
motors, either it be from some adapters (5v 2A) or from good quality 9v batteries.

Material Required

◾ Arduino UNO
◾ Servo Motor
◾ Power Supply
◾ Breadboard
◾ Connecting Wires
(https://bit.ly/2QkLGCH)

Circuit Diagram

NEWS ARTICLES PROJECTS

High Accuracy, 40 KHz Hall-


effect Current Sensor IC for
Starter Generators and
(/news/high- Traction Inverter Control
accuracy-40- (/news/high-accuracy-40-
khz-hall- khz-hall-effect-current-
effect-current- sensor-ic-for-starter-
sensor-ic-for- generators-and-traction-
starter- inverter-control)
generators-
and-traction-
inverter-
control)

Gas Sensors Market is


projected to reach USD 2
(/fullimage?i=circuitdiagram_mic/Circuit-diagram-for-Controlling-Multiple-Servo-Motors-
Billion by 2026 (/news/gas-
with-Arduino.png) (/news/gas- sensors-market-is-
sensors- projected-to-reach-usd-2-
SPONSORED SEARCHES market-is- billion-by-2026)
Coding Software projected-to-
reach-usd-2-
Two Servo Arduino Code
billion-by-
2026)
What is a Servo Motor?
Low Cost Automotive
Sequential LED Lighting IC
Before going into detail, first we should know about Servo Motors.
for Reducing Design
(/news/low- Complexity and
Servo motors (http://circuitdigest.com/electronic-circuits/servo-motor-tester-circuit) are cost- Development (/news/low-
available at different shapes and sizes. A servo motor will have mainly there wires, one is automotive- cost-automotive-sequential-
sequential- led-lighting-ic-for-reducing-
for positive voltage another is for ground and last one is for position setting. The RED wire
led-lighting-ic- design-complexity-and-
is connected to power, Black wire is connected to ground and YELLOW wire is connected for-reducing- development)
to signal. design-
complexity-
• and-
10/68pcs 150W 12-24V No Power Diy
development)
DC Mini Lathe... Woodworking Cutting...
€38 €508 €21 €67 RTG4 Field Programmable
Gate Array (FPGA) in a
Ceramic Quad Flat Pack
(/news/rtg4- (CQFP) for Simplified
Z011 Collet Metal 3- field-
DIY Woodworking System Designs in Satellite
Jaw / 4-Jaw... Precise Liveprogrammable-
Revolving... and Space Probes
gate-array- Applications (/news/rtg4-
€11 €14 €26 €35
fpga-ceramic- field-programmable-gate-
quad-flat- array-fpga-ceramic-quad-
pack-cqfp-for- flat-pack-cqfp-for-
Wish simplified-system-designs-
simplified-
satellite-and-space-probes-
system-
applications)
designs-
satellite-and-
space-probes-
applications)

Automotive
Microcontrollers from
STMicroelectronics to
(/news/automotive-
Maximize Safety and
microcontrollers-Security in Next-Generation
stmicroelectronics-
Domain/Zone Architectures
maximize- (/news/automotive-
safety-and- microcontrollers-
security-for- stmicroelectronics-
next- maximize-safety-and-
generation- security-for-next-
generation-domain-zone-
domain-zone-
architectures)
architectures)

A servo motor is a combination of DC motor, position control system, gears. The position


of the shaft of the DC motor is adjusted by the control electronics in the servo, based on
the duty ratio of the PWM signal the SIGNAL pin.

Simply speaking the control electronics adjust shaft position by controlling DC motor.
This data regarding position of shaft is sent through the SIGNAL pin. The position data to
the control should be sent in the form of PWM signal through the Signal pin of servo
motor.

The frequency of PWM (Pulse Width Modulated) signal can vary based on type of servo
motor. The important thing here is the DUTY RATIO of the PWM signal. Based on this
DUTY RATION the control electronics adjust the shaft.

As shown in figure below, for the shaft to be moved to 9o clock the TURN ON RATION
must be 1/18.ie. 1ms of ON time and 17ms of OFF time in a 18ms signal.
•For the shaft to be moved to 12o clock the ON time of signal must be 1.5ms and OFF time

should be 16.5ms.  This ratio is decoded by control system in servo and it adjusts the
position based on it. This PWM in here is generated by using ARDUINO UNO.

Before Connecting Servos to Arduino, you can test your servo with the help of this Servo
Motor Tester Circuit (http://circuitdigest.com/electronic-circuits/servo-motor-tester-
circuit). Also check our below Servo projects:

◾ Servo Motor Control using Arduino (http://circuitdigest.com/microcontroller-


projects/arduino-servo-motor-control-code-and-circuit)
◾ Servo Motor Control with Arduino Due (http://circuitdigest.com/microcontroller-
projects/servo-motor-control-with-arduino-due)
◾ Servo Motor Interfacing with 8051 Microcontroller
(http://circuitdigest.com/microcontroller-projects/servo-motor-interfacing-with-
8051)
◾ Servo Motor Control using MATLAB (http://circuitdigest.com/microcontroller-
projects/servo-motor-control-using-matlab)
◾ Servo Motor Control by Flex Sensor (http://circuitdigest.com/microcontroller-
projects/servo-motor-control-by-flex-sensor-using-arduino)
◾ Servo Position Control with Weight (Force Sensor)
(http://circuitdigest.com/microcontroller-projects/arduino-servo-motor-control-
by-force-sensor)

Arduino Code Explanation

The complete Arduino code for Multiple Servo Control is given at the end.

Arduino has library for Servo Motors and it handles all the PWM related things to rotate
the servo, you just need to enter the angle to which you want to rotate and there is
function servo1.write(angle); which will rotate the servo to desired angle.

So here we are starting by defining the library for Servo motor.

#include <Servo.h>

In below code, we are initializing all the four servos as Servo1, Servo2, Servo3, and
Servo4.

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

Then, we are setting all the servo’s input pin with Arduino. As shown in the below code,
Servo1 is connected to the 3rd pin of the Arduino. You can change the pins according to
you but keep in mind that it should be a PWM pin. Using a Servo with digital pins of the
Arduino is not reliable.

void setup() {
servo1.attach(3);
servo2.attach(5);
servo3.attach(6);
servo4.attach(9);
}

Now, in the void loop() function we are just rotating all the servo from 0 to 180 degree and
then 180 to 0 degree. The delay used in the below code is used to increase or decrease
the speed of the servo as it effect the increasing or decreasing speed of variable ‘i’.

void loop() {
for (int i = 0; i < 180; i++) {
servo1.write(i);
servo2.write(i);
servo3.write(i);
servo4.write(i);
delay(10);
}
for (i = 180; i > 0; i--) {
servo1.write(i);
servo2.write(i);
servo3.write(i);
servo4.write(i);
delay(10);
}
}

Controlling Multiple Servos with Arduino- Working:

We all face current problem while using more than two servos with one Arduino. The only
solution to this is to connect an external power supply with appropriate amount of current
rating (in this project I used 2A with 9v supply). For External Power supply you can use
Adapters, RPS (Regulated Power Supply Instrument) or good quality 9v volt batteries,
evne you can use your laptop USB port for powering small Servo
(https://circuitdigest.com/article/using-5v-dc-power-supply-from-computer-usb). To use
the external supply you just have to short the Arduino ground to external supply ground.

Use the Arduino code given below to program your Arduino and connect all the Servo
Motors as shown in the circuit diagram with proper power supply to Motors. Therefore, all
servos will work together without any interrupt.

Code

#include <Servo.h>


•Servo servo1;  

Servo servo2;

Servo servo3;

Servo servo4;

int i = 0;

void setup() {

  servo1.attach(3);

  servo2.attach(5); 

  servo3.attach(6); 

  servo4.attach(9); 

void loop() {

  for (i = 0; i < 180; i++) { 

    servo1.write(i);              

    servo2.write(i);     

    servo3.write(i);

    servo4.write(i);         

    delay(10);                      

 }

  for (i = 180; i > 0; i--) { 

    servo1.write(i);                

    servo2.write(i);     

    servo3.write(i);

    servo4.write(i);          

    delay(10);                      

 }

}

 

Video

TAGS ARDUINO UNO (/TAGS/ARDUINO-UNO) ARDUINO (/TAGS/ARDUINO)

INTERFACING (/TAGS/INTERFACING) SERVO MOTOR (/TAGS/SERVO-MOTOR)

Get Our Weekly Newsletter!


Subscribe below to receive most popular news, articles and DIY projects from Circuit Digest

Email Address *
• Name

Country
United States of America 

Subscribe

RELATED CONTENT

(/microcontroller-projects/arduino-touch- (/microcontroller-projects/li-fi-
sensitive-color-changing-plants-using-rgb- communication-between-two-arduino)
leds) Li-Fi based Text Communication between
Touch Sensitive Color Changing Plants Two Arduino (/microcontroller-projects/li-
using Arduino and RGB LEDs fi-communication-between-two-arduino)
(/microcontroller-projects/arduino-touch-
sensitive-color-changing-plants-using-rgb-
leds)

(/microcontroller-projects/measuring-
turbidity-of-water-to-determine-water-
quality-using-arduino-turbidity-sensor)
Measuring Turbidity of Water to
Determine Water Quality using Arduino
and Turbidity Sensor (/microcontroller-
projects/measuring-turbidity-of-water-to-
determine-water-quality-using-arduino-
turbidity-sensor)

(/microcontroller-projects/diy-raspberry- (/microcontroller-projects/how-to-
pi-lora-hat-for-lora-communication- program-arduino-wirelessly-over-
between-raspberry-pi-and-arduino) bluetooth)
DIY Raspberry Pi LoRa HAT - LoRa How to Program Arduino Wirelessly over
Communication between Raspberry Pi Bluetooth (/microcontroller-projects/how-
and Arduino (/microcontroller- to-program-arduino-wirelessly-over-
projects/diy-raspberry-pi-lora-hat-for-lora- bluetooth)
communication-between-raspberry-pi-
and-arduino)

(/microcontroller-projects/arduino- (/microcontroller-projects/interfacing-
nodemcu-based-smart-water-quality- sx1278-lora-module-with-esp32)
monitoring-system-using-iot) Interfacing SX1278 LoRa Module with
Smart Water Quality Monitoring System ESP32 (/microcontroller-
Using IoT (/microcontroller- projects/interfacing-sx1278-lora-module-
projects/arduino-nodemcu-based-smart- with-esp32)
water-quality-monitoring-system-using-
iot)

(/microcontroller-projects/arduino-
ultrasonic-acoustic-levitation-using-hc-
sr04-ultrasonic-sensors)
Simple Ultrasonic Acoustic Levitation
using Arduino and HCSR04 Ultrasonic
Sensor (/microcontroller-
projects/arduino-ultrasonic-acoustic-
levitation-using-hc-sr04-ultrasonic-
sensors)

PREVIOUS POST NEXT POST


How to use ADC in MSP430G2 - Interfacing Hall Sensor with Raspberry
Measuring Analog Voltage Pi
(https://circuitdigest.com/microcontroller- (https://circuitdigest.com/microcontroller-
projects/how-to-use-adc-in- projects/interfacing-hall-sensor-with-
msp430g2-measuring-analog-voltage) raspberry-pi)

COMMENTS

Ida Brandão (/users/ida-


brand%C3%A3o)
(/users/ida-brand%C3%A3o)
Nov 11, 2018

Log in (/user/login?destination=node/1670%23comment-form) or register


(/user/register?destination=node/1670%23comment-form) to post comments
I've replicated this project and it works but I would like to apply it to a
painting and need to make it autonomous. 

Curiously I've tried to connect the 9V battery with respective adapter


directly to the arduino power socket but it didn't work, it only works
connecting the battery with the cables as shown in your video.

When I disconnect the arduino cable from the computer it stops. It


seems it needs the power from the computer + battery to work.

So, how can I make it work without connection to the computer?

Violet (/users/violet)
Nov 21, 2018
• Power you Arduino through the 12V DC jack 
(/users/violet)

Log in (/user/login?destination=node/1670%23comment-form) or register


(/user/register?destination=node/1670%23comment-form) to post comments

Charles C. Spen... (/users/charles-c-


spencer-iii)
(/users/charles-c-spencer-iii)
Jan 14, 2019

Log in (/user/login?destination=node/1670%23comment-form) or register


(/user/register?destination=node/1670%23comment-form) to post comments
I would suggest showinga ubec and showing it connected to a ac/dc
plug. I also would suggest to show it completed in a project box with
ready servo plugs. Also, the 3.3v, 5v, and the 12v vin could use a
multimeter test set on the project box making this an easy test center.

Kevin Vishal K J (/users/kevin-vishal-k-j)


Jan 22, 2019
(/users/kevin-vishal-k-j)
Hy guys i loved your work... but i want to do a
Log in (/user/login?destination=node/1670%23comment-form) or register
(/user/register?destination=node/1670%23comment-form) to post comments
minor change. I want to add an switch to make the motor rotate forward
and again press dat switch to make it move backward .. plz edit the code
and also i need circuit diagram too... thank you in advance

anna (/users/anna-2)
Jun 10, 2019
(/users/anna-2)
Nice work! Hello, Im new in programming. But may you
Log in (/user/login?destination=node/1670%23comment-form) or register
(/user/register?destination=node/1670%23comment-form) to post comments
help me or give suggestion how could I add adjustment if an LDR is
involve? I want to make an LDR  that will use controll the the rotation of
servo so that the LED bulb brightness will adjust. thanks in advance!

LOG IN (/USER/LOGIN?DESTINATION=NODE/1670%23COMMENT-FORM) OR REGISTER


(/USER/REGISTER?DESTINATION=NODE/1670%23COMMENT-FORM) TO POST
COMMENT

CATEGORIES POPULAR NEWSLETTER

Embedded ROBOTICS (/ROBOTICS- Sign Up for Latest News


Electronics PROJECTS)
Connect with us on social media and stay
(https://circuitdigest.com/embedded) Enter your email
updated with latest news, articles and projects!
555 CIRCUITS (/555-TIMER-
CIRCUITS)
• Power Electronics ARDUINO PROJECTS Subscribe
(https://circuitdigest.com/power- (/ARDUINO-PROJECTS)
(https://www.facebook.com/circuitdigest/)
(https://twitter.com/CircuitDigest)
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IPdLmw)
(https://www.instagram.com/circuit_digest/)
(https://www.pinterest.com/circuitdigest/)
electronics)
RASPBERRY PI PROJECTS
(/SIMPLE-RASPBERRY-PI-
(https://www.linkedin.com/company/circuit-
Analog Electronics
PROJECTS-FOR-BEGINNERS)
(https://circuitdigest.com/analog-
digest/) electronics)
ELECTRONICS NEWS
(HTTPS://CIRCUITDIGEST.COM/NEWS)
Internet of Things
(https://circuitdigest.com/internet-
ELECTRONICS FORUM
of-things) (HTTPS://CIRCUITDIGEST.COM/FORUMS)

Audio Electronics
CALCULATORS
(https://circuitdigest.com/audio-
(HTTPS://CIRCUITDIGEST.COM/CALCULATORS)
electronics)

Electric Vehicles
(https://circuitdigest.com/electric-
vehicles)

Events
(https://circuitdigest.com/events)

Copyright © 2020 Circuit Digest (http://circuitdigest.com/). All rights reserved. Privacy Policy (http://circuitdigest.com/privacy-policy) | Cookie Policy
(https://circuitdigest.com/cookie-policy) | Terms of Use
(https://circuitdigest.com/terms-of-use) | Contact Us
(http://circuitdigest.com/contact) | Advertise (http://circuitdigest.com/advertise)

You might also like