Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » How to Control Multiple Servo Motors with Arduino
Arduino Projects

How to Control Multiple Servo Motors with Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:August 22, 20221 Comment4 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Control Multiple Servo Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this tutorial, we will learn How to Control Multiple Servo Motors with Arduino. We will interface 4 servo Motors with Arduino and control its rotational movement using Pulse Width Modulation Signal. But before that let’s learn about the servo motor it’s working and also its applications.


What is a Servo Motor?

A servo motor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity, and acceleration. It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.

Servo Motor Block Diagram

Servomotors are not a specific class of motor although the term servomotor is often used to refer to a motor suitable for use in a closed-loop control system. There are many types of servo motors and their main feature is the ability to precisely control the position of their shaft.

Servo Motors Types




Construction of Servo Motor

The Servo motor is DC motor which has 5 following parts:

Servo Motor Construction

Stator Winding: This wound on the stationary part of the motor. It is also known as field winding of the motor.

Rotor Winding: This wound on the rotating part of the motor. It is also known as an armature winding of the motor.

Bearing: This is of two types, i.e font bearing and back bearing which are used for the movement of the shaft.

Shaft: The armature winding is coupled on the iron rod is known as the shaft of the motor.

Encoder: It has the approximate sensor which determines the rotational speed of motor and revolution per minute of the motor.


Working of Servo Motor

The servo motor works on the phenomenon of the automatic closed-loop system. The controller is required for this closed-loop system. This controller is composed of a comparator and a feedback path. It has one output and two inputs. For producing an output signal, the comparator is used to compare the required reference signal and the output signal is sensed by the sensor.

 Block Diagram

The input signal for the motor is termed as a feedback signal. On the basis of the feedback signal, the motor starts working. Comparator signal is called a logic signal of the motor. The motor gets ON for the desired time when the logical difference is higher and the motor gets OFF for the desired time when the logical difference is lower. Thus, a comparator is used to decide the ON/OFF position.



Controlling of Servo Motor Using PWM Signal

The servo motors can be controlled by Pulse Width Modulation (PWM). These send electric signals of inconsistent width to the motor. The width pulse is varied in the range of 1 millisecond to 2 milliseconds and transfer this to the servo motors with repeating 50 times in a second. The width of the pulse controls the angular position of the rotating shaft. There are 3 terms that are used to control the servo motor:

C++
1
2
3
1. Maximum Pulse
2. Minimum Pulse
3. Repetition Rate

The servo moves with the pulse of 1 millisecond to turn motor towards 0˚ whereas a pulse of 2 milliseconds to turn motor towards 180˚. The servo turns to the 90˚ with the pulse of width 1.5 milliseconds.

Servo Motor PWM

When servo motor is commanded to move by applying pulses of appropriate width, the shaft moves to and holds the required position. If an external force is trying to change the position of the shaft, the motor resists changing. Pulses need to be repeated for the motor to hold the position.


How to Control Multiple Servo Motors with Arduino

Here, we are going to show you how to control Multiple Servo Motors with Arduino. Connecting multiple Servo Motors with Arduino seems to be easy. But if we connect all the Servos to Arduino supply, they won’t work correctly. This is due to the lack of enough current to drive all the motors. So you have to use a separate external power supply for the motors like Adapters (5v 2A) or 9v batteries.

We are using three SG-90 Servo Motor for a practical demonstration. Below is the circuit diagram.

Control Multiple Servo Arduino




Source Code/Program

Copy and upload this Source Code/Program for Controlling multiple servo motors with Arduino.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <Servo.h>
 
Servo servo1;
Servo servo2;
Servo servo3;
 
int i = 0;
 
void setup() {
servo1.attach(3);
servo2.attach(5);
servo3.attach(6);
}
 
void loop() {
for (i = 0; i < 180; i++) {
servo1.write(i);
servo2.write(i);
servo3.write(i);
delay(10);
}
for (i = 180; i > 0; i--) {
servo1.write(i);
servo2.write(i);
servo3.write(i);
delay(10);
}
}


Code Explanation

Arduino has a library for Servo Motors and it handles all the PWM related things to rotate the servo.

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

Then we are initializing all the three servos as Servo1, Servo2, Servo3.

And then we set setting all the servo’s input pin with Arduino.

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 using the variable ‘i’.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleFan Speed Measurement using IR Sensor & Arduino
Next Article IoT Based RFID Attendance System Using Arduino ESP8266 & Adafruit.io

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 1 Comment

1 Comment

  1. Oleg on June 16, 2020 5:59 PM

    What about 100 servos

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • MAX30102 & Arduino: Heart Rate + Blood Oxygen Monitoring
    MAX30102 & Arduino: Heart Rate + Blood Oxygen Monitoring
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.