• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Arduino Projects / How to Interface Servo motors with Arduino

How to Interface Servo motors with Arduino

Last Updated on December 5, 2024 by Swagatam 4 Comments

In this post I have explained what servo motor is, how it functions, how to interface with microcontroller and what make this motor special from other motors.

Being an electronics enthusiast we would have come across many kinds of motors, here we are going to take a look at special type of motor called servo motor.

What is a Servo motor?

Servo motor or simply servo is a special type of motor which is designed for precise control over position, acceleration and velocity. Unlike all other types motor, servo can only rotate 180 degree bi-directional. It has mechanical gears and stopper which limit the angular rotatory of servo.

Typical servo motor: 

IMG 20161207 161719 HDR 2

The servo motors are used in robotics, CCTV cameras, RC cars, boats, toy aircrafts etc. Servos are used where we no need continues rotatory motion, but lock in a specific position or move some load with controlled velocity within the moveable angular limit.

Servo aren’t simply a motor like other types, but it is module, which combines of a normal DC/AC motor, a group of gears, control electronics and a feedback system. Let’s look at the each mentioned stages in detail.

DC/AC motor which is employed on a servo module can be brushless or brushed motor, on most of the hobby servos DC motor is used and AC motors are used in industrial applications. The motor gives rotational input to the servo. The motor rotates at several hundred RPM inside the servo and output rotation is about 50 or more times less of its RPM.

The next stage is the gear assembly, which control the angular rotation and speed of servo. The gear may be made from either plastic or metal depending on how bulky the load is. Generally DC motors are run at high RPM and low torque; the gear assembly will convert the excess RPM into torque. Thus a small motor can handle a huge load.

The next stage is control electronics which constitutes of MOSFETs and ICs for controlling the rotation of the motor. A feedback system is always present in servo motors for tracking the current position of the actuator.

In servos generally a feedback component is a potentiometer, which is directly connected to rotating actuator. The potentiometer acts as voltage divider which is fed to the control electronics. This feedback helps control electronics to determine the amount of power given to the motor.

A servo motor in a fixed position will reluctant move from its current position if any external force try to disturb. The feedback system monitors the current position and powers the motor against external disturbance.

The above scenario is same when the servo is moving its actuator. The control system will compensate the external force and move in determined velocity.

By now you know quite a bit about servo motor and its functioning mechanism. Let’s see how to control the servo motors using microcontroller.

Servo motors have 3 terminals unlike other motors which have 2 terminals, two for supply (5V nominal) and one for control signal. The wires are coloured for easy identification of terminals.

The control signals of servos are PWM at 50Hz frequency. The pulse width of the signal determines the position of the actuator arm. A typical hobby servo motor operates from 1 to 2 milliseconds pulse width.

Applying 1 ms pulse width control signal will keep the actuator at 0 degree position. Applying 2 ms pulse width control signal will keep the actuator at 180 degree position. Applying signals in between 1-2 ms will keep the actuator within 0-180 degree angle. This can be better understood by given below image.

 

PWM2BServo

By now you would have understood how a servo is controlled by pulse width modulation (PWM).

Now let’s learn how to interface a servo motor with Arduino.

Circuit diagram: 

how to interface a servo motor with Arduino.

The wiring is easy and self-explanatory. You need external power supply if you are using a bulky servo motor. If you try to power from arduino power’s supply you will end-up overloading the USB port on the computer.

If you have servo similar which is illustrated at the beginning of the article, then you may power it from arduino 5V supply, also shown in author’s prototype.

Author’s prototype: 

IMG 20161206 085956 2

Arduino need servo library for handling it, it made our task easy and it’s already in the Arduino IDE.

Program:

//--------Program developed by R.Girish--------//
#include <Servo.h>
Servo motor;
int pos = 0;
int t=10;
void setup()
{
motor.attach(7);
}
void loop()
{
A:
pos=pos+1;
motor.write(pos);
delay(t);
if(pos==180) { goto B;}
goto A;
B:
pos=pos-1;
motor.write(pos);
delay(t);
if(pos==0) { goto A;}
goto B;
}
//--------Program developed by R.Girish--------//

The above program will sweep the actuator 0 to 180 degree right and 180 to 0 degree left and cycle repeats. This is a simple program for testing the servo; you may need to write your own code for your customized applications.

You'll also like:

  • 1.  Wireless Office Call Bell Circuit
  • 2.  H-Bridge Sine Wave Inverter Circuit using Arduino
  • 3.  Using Triacs for Controlling Inductive Loads
  • 4.  Automatic Torque Optimizer Circuit in Electric Motors
  • 5.  Arduino SPWM Generator Circuit – Code Details and Diagram
  • 6.  Ultrasonic Fuel Level Indicator Circuit

About Swagatam

I am an electronics engineer with over 15 years of hands-on experience. I am passionate about inventing, designing electronic circuits and PCBs, and helping hobbyists bring their projects to life. That is why I founded homemade-circuits.com, a website where I share innovative circuit ideas and tutorials. Have a circuit related question? Leave a comment.... I guarantee a reply!

Previous Post: « Two Pipe Water Pump Valve Controller Circuit
Next Post: Understanding Motorcycle Voltage Regulator Wiring »

Reader Interactions

Comments

  1. GR says

    December 11, 2016 at 10:23 am

    Hi,
    I will try make a article regarding stepper motor soon.
    Regards

    Reply
  2. Unknown says

    December 11, 2016 at 4:24 am

    Hello Very useful tutorial for me. As I working on project which contains servo and stepper motor so can you share working and circuit diagram of stepper with Arduino nano. Thank you.

    Reply
  3. Kuldeep Tripathi says

    December 10, 2016 at 12:29 pm

    Hello Swagatam this Is Kuldeep And i want a simple fm transmitter circuit which we use to make a project and this tarsmition is also catch by mobile fm Radio please help me

    Reply
    • Swagatam says

      December 10, 2016 at 3:42 pm

      hello kuldeep, you can try the following idea,

      https://www.homemade-circuits.com/2012/01/how-to-make-wireless-speaker-system.html

      Reply

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Subscribe to New Circuit Ideas

Categories

  • Arduino Projects (87)
  • Audio and Amplifier Projects (132)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (82)
  • Datasheets and Components (103)
  • Electronics Theory (143)
  • Free Energy (37)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (19)
  • Health related Projects (25)
  • Home Electrical Circuits (12)
  • Indicator Circuits (14)
  • Inverter Circuits (87)
  • Lamps and Lights (142)
  • Meters and Testers (69)
  • Mini Projects (46)
  • Motor Controller (64)
  • Oscillator Circuits (27)
  • Pets and Pests (15)
  • Power Supply Circuits (108)
  • Remote Control Circuits (50)
  • Security and Alarm (64)
  • Sensors and Detectors (101)
  • Solar Controller Circuits (59)
  • Temperature Controllers (42)
  • Timer and Delay Relay (49)
  • Transmitter Circuits (29)
  • Voltage Control and Protection (37)
  • Water Controller (36)

Calculators

  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator
  • Filter Capacitor Calculator
  • Buck Converter Calculator
  • Boost Converter Calculator
  • Solar Panel, Inverter, Battery Calculator
  • Wire Current Calculator
  • SMPS Transformer Calculator
  • IC SG3525, SG3524 Calculator
  • Inverter LC Filter Calculator

People Also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Recent Comments

  • Swagatam on Best Electronic Circuit Projects
  • TOMMY on Best Electronic Circuit Projects
  • Swagatam on Inverter Circuit with Feedback Control
  • Jerry Adeosun on Inverter Circuit with Feedback Control
  • Swagatam on Contact

Company

  • Privacy Policy
  • Cookie Policy
  • About Me
  • Contact
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Quora
  • Stack Exchange
  • Linkedin
  • © 2025 · Swagatam Innovations