9G Servo Mod
9G Servo Mod
Overview
We will learn how to use the Arduino to control a servo motor and make it turn.
Materials
Arduino Uno x 1
Servo x 1
DuPont wires
Product Description
A servo motor is a motor that can turn to an accurate position based on signals sent to it. It consists of a
motor, gear a position detector and control circuitry. There is a feedback loop such that the motor is
controlled based on the position sensor and the control input. Generally servo motors have a range of 0 to
180 degrees. This servo motor is controlled by the length of electrical pulses sent to it.
The are suitable for control systems that require changing constantly changing angles that need to be
maintained. They are used in remote control toys, such as model aircraft, model boats and are commonly
used in robots. They are often just referred to as servos.
There are many different specifications for servos, but all the steering gear have three external wires colored
brown, red and orange. For this servo, brown is ground, red is positive and orange is the signal line.
The rotation angle of the servo is adjusted by the duty ratio of the PWM (Pulse Width Modulation) signal. The
duty cycle is how long the signal is positive for in once cycle of a pules. The cycle length of the standard
PWM signal is fixed at 20 ms (50 Hz). Theoretically, the pulse width distribution should be within 1 ms and
2ms, however,in fact the pulse width can be from 0.5ms to 2.5ms. The pulse width corresponds to steering
gear angle from 0°~ 180°. Please be aware that different servo Brands may have different steering angles
for the same signal.
Specification:
Weight:9g
Size:23x12.2x29mm
No-load operating speed:0.12s/60°(4.8V);0.10s/60°(6.0V)
Torque:1.6kg·cm(4.8V)
Operating temperature:-30~+60 degrees Celsius
Dead zone setting: 5 microseconds
Working voltage:3.5V~6V
The Aduino has its own Servo function for servo control. The advantage of using this is that it is already
written for you, though it is restricted to only two servos using its digital pins 9 and 10.
Wiring Diagram
Connect the servo to the digital 9 interface and write a program to move the servo to the position where the
user inputs the angle number.
Sample code
#include <Servo.h>
void setup()
{
myservo.attach(9); // Setting the pin of the servo
}
void loop()
{
// 0° to 180°
for(pos = 0; pos < 180; pos += 1)
{
myservo.write(pos);
delay(15);
}
// 180°to 0°
for(pos = 180; pos>=1; pos-=1)
{
myservo.write(pos);
delay(15);
}
}
Results
After uploading to the Arduino, it can be seen that the servo starts to run from 0° to 180° and then back from
180° to 0°