Lesson 17 Servo
Lesson 17 Servo
Introduction
In this lesson, you will learn how to use Servo. Servo is a type of geared motor
that can only rotate 180 degrees. It is controlled by sending electrical pulses
from your UNO R3 board. These pulses tell the servo what position it should
move to.
Hardware Required
1 * RexQualis UNO R3
1 * Servo
Principle
SG90 Servo
Tiny and lightweight with high output power. Servo can rotate approximately
180 degrees (90 in each direction), and works just like the standard kinds but
SMALLER. You can use any servo code, hardware or library to control these
servos. Good for beginners who want to make stuff move without building a
motor controller with feedback & gear box, especially since it will fit in small
places. It comes with a 3 horns (arms) and hardware.
Specifications
•Weight: 9 g
•Temperature range: 0 ºC – 55 ºC
Position "0" (1.5 ms pulse) is mi ddle, "90" (~2 ms pulse) is all the way to the
right, "-90" (~1 ms pulse) is all the way to the left.
Code interpretation
#include <Servo.h>
void setup() {
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180
degrees
// in steps of 1 degree
myservo.write(pos);
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0
degrees
myservo.write(pos);
Experimental Procedures
Schematic Diagram
Step 2:Open the code:Servo_Code
Step 3: Attach Arduino UNO R3 board to your computer via
USB cable and check that the 'Board Type' and 'Serial Port' are
set correctly.
Then, You can see the servo turns anticlockwise and then
turns clockwise.
If it isn’t working, make sure you have assembled the circuit
correctly, verified and uploaded the code to your board. For
how to upload the code and install the library, check Lesson 0
Preface.