Introduction: Arduino Servo Control

This tutorial is about servo control on Arduino. Arduino has got
a library for servo control. This tutorial explains how to control servo by using in-built library of Arduino. It has got two examples of servo control to give a better understanding of servo control.

Step 1: Introduction:

A step by step illustrated basic tutorial for Arduino. This tutorial explains Servo motor control through Arduino.

We have included two exmaples in this tutorial.

The meaning of servo is feedback. So a servo is an actuator that takes feedback itself and moves precisely. Example of preciseness and feedback can be understood by a daily life example, suppose you pull up/down glass of your car window, You push up/down the power window button and keep on watching the actual position of glass as it reaches to the desired position you releases the button. So this is feedback, we are taking feedback here, if it would be an feedback based system we would have to tell open window by 10%-20%.

Lets come back to servo motor. Servo motor rotate from 0 degree to 180degree. We send the command to servo as it reaches to the commanded value it stops there. The below diagram exhibits how it rotates and its wire interface.

Arduino has got a library to control servo. It is – Servo.h.
This library can control above shown servo motors. This library supports up to 12 servos on most Arduino boards and 48 servos on Arduino Mega. It disables analogWrite() for Pin 9 & Pin 10 except Arduino Mega.

This tutorial is made on Original Arduino UNO.

Step 2: Required Hardware:

1 Arduino UNO - 1

2 Breadboard - 1

3 Servo Motor - 1

4 Preset 10k - 1

5 Jumper wire male to male - 4

6 Jumper wire male to female - 3

Users can buy the Arduino Starter Kit online from Robo India Shop:

Step 3: Building Circuit

Here is the schematic diagram of servo with Arduino:

Step 4: Circuit-1

This is first example of servo control. Servo alone is controlled through Arduino. In this examples servo takes 5 motions-
1. 0 degree to 45 degree

2. 46 degree to 90 degree

3. 91 degree to 135 degree

4. 136 degree to 180 degree

5. 180 degree to 0 degree (Back to zero)

After completing every movement it stops there for one second.

To run this practical example make following circuit with the help of above mentioned components.

Step 5: Programming- 1

Once we are done with circuit part, here is our programme to this
circuit. All of the commands are explained in the comment section.

Step 6: Circuit - 2

This is second example of Servo Control. In this example We are controlling servo through Analog input. Analog input is taken from a potentiometer. And command of motion is given to the attached servo as per the input we are getting from potentiometer.

Make the following circuit-

Step 7: Programming- 2

Here is programming for example - 2 (above mentioned circuit).

Points to under stand.

1. Analog input is taken through Potentiometer on Pin A0. It will give us value from 0 to 1023.

2. The servo library need value 0 to 180 to give command to servo.

3. So we will convert our input values (0-1023) to the command value for servo (0-180).

4. This converted value is sent to the servo through Pin 3.

The following programme explains all of the command in comment sections.

Step 8: Output:

Here is the output of this tutorial. This video contains both of the practicals we have done above