Professional Documents
Culture Documents
2.2.4.2 Alternate Lab - Servo - ILM
2.2.4.2 Alternate Lab - Servo - ILM
Instructor Note: Red font color or gray highlights indicate text that appears in the instructor copy only.
Topology
Objectives
Connect the circuits between the breadboard and RedBoard
Load and run the sketch in the Arduino IDE
Control the rotation of a small servo motor
Background / Scenario
This lab will make use of a potentiometer to change resistance based on the position of the knob on the
potentiometer. The varying resistance will then be used to control the voltage sent to the Servo. Varying the
voltage will cause the Servo to change positions.
© 2022 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 1 of 4
Lab – Servo
Required Resources
SparkFun Inventors Kit (SIK) or equivalent components
PC configured with Arduino drivers and Arduino software
SparkFun SIK Guide Code example files
© 2022 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 2 of 4
Lab – Servo
b. Verify and compile the sketch to create an executable firmware that can be uploaded to the flash memory
of the microcontroller.
c. Make sure the RedBoard is connected to the PC with the USB cable. Upload the firmware to the
RedBoard.
© 2022 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 3 of 4
Lab – Servo
Note: If the firmware cannot be uploaded successfully, you may refer to Lab 2.2.2.5 for
troubleshooting. Make sure that the correct COM port is used to connect the RedBoard.
d. Rotate the knob on the Potentiometer clockwise. The Servo motor should turn clockwise depending on
how much the knob is rotated. Rotate the knob on the Potentiometer counterclockwise. The Servo motor
should also turn counterclockwise depending on how much the knob is rotated.
Reflection
Review the code. Which function and its parameter should be altered so that moving the potentiometer a lot
only moves the servo a little?
_______________________________________________________________________________________
_______________________________________________________________________________________
The analog pin values (input from the potentiometer) on the microcontroller vary from 0-1023, but we want to
control the servo motor to turn only between 0-180 degrees. The map() function takes a range of values and
outputs a different range of values that can contain more or fewer values than the original. In this case, we
are taking the range 0-1023 and mapping it to the range 20-160 (degrees).
© 2022 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 4 of 4