Week 10 Lab Report – Control Servo using Potentiometer

Objective: Control servo motor with the potentiometer, then make the servo’s shaft rotate in different directions.

Materials: Arduino Uno, Hitec HS-422 servo motor, potentiometer, breadboard, jumper wires, USB A/B

Procedure:

1. Connect Arduino Uno 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➝Servo➝Knob and check the code in order to determine what signal pins are assigned for the servo and potentiometer. In our case, potentiometer uses Analog pin 0, while servo is attached to Digital pin 9 (PWM).

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 breadboard’s power bus strip, black one (ground) goes to breadboard’s ground. 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. Hook up potentiometer to the Arduino. The same procedure as for the servo, but with signal wire going to A0.

7. Connect breadboard’s power bus strip to the Arduino’s 5V pin, and ground bus strip to the Arduino’s GND pin using jumper wires.

IMG_5273

8. Compile and upload Knob sketch. Now rotation of the servo’s shaft is controlled by the pot.

9. Try to make the shaft rotate in the opposite direction. There are two ways to do that: using software or using hardware.

10. Software method: Go to the ‘void loop’ section of the Knob sketch and swap mapping arguments from code initialto  code change . Compile and upload the sketch again. Now the rotation direction is reversed.

11. Hardware method: Reverse potentiometer’s power and ground pins. Put power wire into ground pin, and ground wire into power pin. Now the direction is reversed without recompiling and reuploading the sketch.

Results: The procedure was successful. We figured out software method very fast, but hardware method was discovered only after Professor Baker’s explanation.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply