Week 6 · Drivers & Motors
Session 27: Servo motors
Learning outcomes
- Explain how pulse width sets a hobby servo's angle
- Control a servo with Servo.h from a potentiometer
- Measure the servo pulse width and period on the oscilloscope
- Power a servo from its own supply with a common GND
Kit and components
- Uno, hobby servo, 10 kΩ potentiometer, separate 5 V supply, breadboard
- Oscilloscope
Pre-reading about 20 min
Students read these on their phones before class. They are listed on the student Before class page.
Session plan
- 0:0010 minRecap
Quiz: drivers
- 0:1020 minDemo
Pulses, not brightness
Show the 20 ms servo frame on the scope and how the pulse width follows write(angle). Point out that Servo.h disables PWM on pins 9 and 10.
- 0:3040 minBuild
Knob-controlled servo
Students build the worked sketch with the servo on its own supply and a common GND.
- 1:1035 minMeasure
Pulse width against angle
Students record the pulse width at 0, 45, 90, 135 and 180 degrees and plot it in the logbook.
- 1:4515 minWrap-up
Why a separate supply?
Checkpoint: ready to move on?
Each student's servo follows the potentiometer without resetting the board, and they have a table of pulse width against angle.
Extension for fast finishers
Sweep the servo with millis() instead of delay() so a button can stop it at any angle.
Catch-up path
Run a fixed write(90) sketch first and confirm the 1.5 ms pulse before adding the potentiometer.
Homework and practice
Pre-reading for S28.
Facilitator notes
- A servo powered from the Uno 5 V pin often resets the board when it moves. Insist on the separate supply.