Week 9 Lab Report – Servos

Objective: Hook up servo motor to Arduino and make it accomplish different tasks.


a) Hardware: Arduino Uno, Hitec HS-422 servo, USB A/B cable, 3 jumper wires

b) Software: Arduino IDE, Servo Library


1. Connect Arduino board to the computer, using USB A/B cable.

2. Open Arduino IDE.

3. Go to the Tools menu and choose a correct board (Arduino Uno) and then a serial  port (/dev/tty.usbmodem3a21) from pull-down menus.

4. Go to File➝Examples➝01.Basics➝Blink and run the “Blink” example just to verify that the board is working properly.

5. Hook up servo motor to Arduino using 3 jumper wires: the yellow one (signal) goes to PWM pin 9, red one (power) goes to the 5V pin, black one (ground) goes to GND pin. On the servo’s JST 3 wire cable, the red power wire is always in the middle, so no matter how you rotate the cable, you will always know were the power is.


6. Go to File➝Examples➝Servo➝Sweep, then compile and upload the sketch to the board. This sketch sweeps the shaft of the servo from 0 to 180 degrees in 1 degree increments. Because the 15ms delay had been set for the servo to reach the position, the shaft moves pretty slow.

7. Try to change parameters and see what happens. We played with different delay times, angles, degrees of increment and even pin numbers.

8. Then we modified the code a little bit deleting the FOR loop and setting position one to 0 degrees and position 2 to 180 degrees. This modification allows the servo to go from 0 degrees straight to 180 and back, without gradually incrementing  the number of degrees.


While configuring our serial port, we encountered one problem: Arduino IDE didn’t give us an option for the usb modem in the pull-down menu. It turned out that our USB A/B cable wasn’t working properly, so we switched to another one. Other than that, everything was working fine and the procedure was successful.

A side note is that the Hitec HS-422 servo has a very good torque, because when we were trying to stop the rotation of the shaft with the fingers, we weren’t able to do so, because the shaft’s force was higher than the finger’s force.


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply