Introduction: Learn SERVO Control (at a Glance)

Picture of Learn SERVO Control (at a Glance)

In this module you will be learning about controlling a micro or mini Servo that is compatible with arduino.A servo motor is generally used in any automation projects that has a moving parts.It plays a very important role in Robotics,the precise movements of each and every arm of a robot is controlled by Servo.Thus i think this would be more than enough to know how important this tiny device is.

This can be used in mini projects also where you want to move a thing in precise angles.Thus a Servo can be used very easily with arduino,by just writing a code of 3-4 lines.

It can be learned very simply in just 7-10 minutes,get benefited..........................!

Step 1: Contents

Picture of Contents

*Servo motor basic understanding.

*connection and wire details.

*simplest coding to control the servo using Arduino.

*Servo applied in real time project examples.

LET'S LEARN .....................................................GET EXCITED.................................................................!

Step 2: Basics of Servo...

Picture of Basics of Servo...

Servo motors have been around for a long time and are utilized in many applications. They are small in size but pack a big punch and are very energy-efficient. Servo motors are also used in industrial applications, robotics, in-line manufacturing, pharmaceutics and food services.

But how do the little guys work?

The servo circuitry is built right inside the motor unit and has a positionable shaft, which usually is fitted with a gear. The motor is controlled with an electric signal which determines the amount of movement of the shaft.

Servos are controlled by sending an electrical pulse of variable width, or pulse width modulation (PWM), through the control wire. A servo motor can usually only turn 90° in either direction for a total of 180° movement both the clockwise or counter-clockwise direction.

When these servos are commanded to move, they will move to the position and hold that position. If an external force pushes against the servo while the servo is holding a position, the servo will resist from moving out of that position. The maximum amount of force the servo can exert is called the torque rating of the servo. Servos will not hold their position forever though; the position pulse must be repeated to instruct the servo to stay in position.

Step 3: Connection and Wiring

Picture of Connection and Wiring

There are two types of standard servo wire color coding available.One is generally meant for mini servo,the other one is meant for normal servo.


orange-------------------------------->signal to be connected to the arduino digital pin.


brown--------------------------------->gnd,ground pin


white------------------------------------>data/signal to be connected to the arduino.


black------------------------------------->gnd,ground pin.

That's all about the wiring...............................................!

Step 4: Simple Coding for Setup

Picture of Simple Coding for Setup

making the code is the most simplest job of all!

you have to know only two basic things before starting your code,The arduino software IDE provides us an inbuilt library in it especially to control a Servo motor thus making our jobs simpler.

To include the library in your code you have to type the following text at the beginning of your code


or you can simply include the library by clicking skecth------>Import library-------->Servo

both method does the same job you may choose the convenient way for you!

Now,you have to name your servo i.e,you have to create an servo object by using a keyword called Servo.

example: Servo instructable;

now the name of the object in this example is instructables.

Next,to assign a digital pin of your arduino to the signal pin of the Servo the following code is used,


now the signal pin can be connected to the digital pin 2 of the arduino.

That's all with the setup,now we will move on to the control part.

The keyword used to position your Servo shaft at an particular angle is object_name.write(angle 0-180);

example: instructable.write(30);

the above coding sends a signal to the servo and tells it to assign at 30 degree.

Step 5: Coding for Control

Picture of Coding for Control

Now after you have assigned the initial position of your servo you can move to any position by using the same code servo_name.write(),but the problem is it move quickly thus it may vibrate a lot and not move smoothly.Thus the solution is using a suitable delay().

This can be easily done by the use of for loop() as shown in the figure.

In this the first 30 in the for loop represents the current servo position,and the 180 is the desired position.

Thus you might have known the basics of the how to use an Servo with arduino.

Step 6: Applications

Listed below are some of my instriuctables where i have used a servo refer it for further understanding,

1.wifi control door lock.

2.Bluetooth fish feeder.

Hope you like this instructable!

few upcoming topics

1.ESP8266 simple control.


3.LCD display

..................and lot more follow me for further useful informations.


About This Instructable




Bio: I like to do robotics and automation projects.* denke anders!(think different)
More by einzigartig arun:Learn SERVO Control (at a Glance)Learn ARDUINO(in 20 Mins)HDPE Bottle Recycle(using Pressure Cooker)
Add instructable to: