Javatpoint Logo
Javatpoint Logo

Arduino Servo Motor

The principle of the servo motor is based on Pulse Width modulation (PWM). It means that the duration of pulses applied to the specific control pin controls the angle of rotation of the motor.

The construction of the servo motor is similar to a DC motor. It means that it has a rotor, stator, and control assemblies. It has closed-loop feedback for controlling the torque and speed.

The advantages of a servo motor are listed below:

  • High efficiency
  • High output power
  • Small size
  • Good power
  • High precision
  • rapid acceleration of loads

The applications of servo motors are machinery, automated manufacturing, robotics, radio controller airplanes, etc. The controller is considered as an essential part of the servo motor.

The movement in a servo motor is determined by an electric signal that can be either digital or analog.

The Servo library is the library that permits the Arduino to work with servo motors.

What is the Servo library, and why is it used?

The servo library allows controlling the integrated shaft and gears. We can also position shaft at different angles between 0 and 180 degrees. The servo library on Arduino boards can support upto 12 motors, while on Arduino Mega board, it can support upto 48 motors.

It is because servos do not interfere with the functionality of PWM pins on the Arduino Mega board. On other Arduino boards, the servo library disables the PWM pin 9 and 10 even if the servo is connected to these pins.

The use of motors on Mega is also limited. It means we can use 12 motors on Arduino Mega. But, using 12 to 23 motors on the Mega board can disable the PWM functionality on the pin number 11 and 12.

What is the difference between a regular motor and a servo motor?

The difference between regular motor and servo motor are listed below:

  • The output shaft of the servo motor can be moved to a specific velocity, position, and angle while regular motors cannot.
  • The feedback from the motor is used by the servo motor control loop, which helps the motor to reach the desired velocity and position.

What is the difference between a stepper motor and a servo motor?

The difference between stepper motor and servo motor are listed below:

  • The servo motor requires a control loop feedback. The control loop is used to monitor the current distance and velocity. Due to this, it is more reliable than the stepper motor.
  • Servo motors usually have a low pole count while the stepper motors have high.
  • The speed curve of the servo motor is more flexible compared to the stepper motor.
  • The stepper motor has low speed and accuracy than the servo motor.


Let's start the project with Arduino.

Here, the servo motor is simply connected to the Arduino.

Hardware Required

The components required for the project are listed below:

  • 1 x Mini Servo motor
  • Arduino UNO R3 board (We can take any Arduino board).
  • Jump wires

Mini Servo Motor: It is defined as a tiny motor that can approximately rotate upto 180 degrees. It works similar to the usual servo motor, but smaller in size.

We can also use any servo motor. The connection and procedure would be the same.


The project allows us to control the shaft at angles between 0 and 180 degrees. We can also set the rotation of the shaft at different speeds.

Servo motor has three terminals signal, power, and ground. The signal terminal is usually connected to the 5V pin of the Arduino board with the help of a wire.

The ground, power, and signal wire are represented by black, green, and red colors.

Structure of the project

The structure of the connection or project is shown below:

Arduino Servo Motor


The steps to set up the connection are listed below:

  • Connect the signal terminal of the servo motor to the 5V pin of the Arduino board.
  • Connect the power terminal of the servo motor to pin 5 of the Arduino board. We can connect the power terminal of the motor to any digital PWM pin on the Arduino board.
  • Connect the ground terminal of the servo motor to the GND pin of the Arduino board.


Consider the below code:

Steps to upload the code to the project

The steps are listed below:

  • Open the Arduino IDE.
  • Select the type of board from Tools -> Board -> Arduino UNO.
  • Select the port from Tools -> Port -> COM..
  • Upload the sketch to the connection diagram.

Connection Diagram

We will show the connection using the Simulator so that the connections become clearer and more precise.

We can make the same connection using the hardware devices.

Arduino Servo Motor


The shaft will rotate 90 degree in each direction i.e. approx. 180 degrees.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA