Week 6 · Drivers & Motors

Session 27: Servo motors

Teach & build120 minLesson 17: 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.

  1. Lesson 17: Control signal: pulse width
  2. Lesson 17: Servo.h and write(angle)
  3. Lesson 17: Power and common ground
  4. Theory Reference: Servo output

Session plan

  1. 0:0010 min
    Recap

    Quiz: drivers

  2. 0:1020 min
    Demo

    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.

  3. 0:3040 min
    Build

    Knob-controlled servo

    Students build the worked sketch with the servo on its own supply and a common GND.

  4. 1:1035 min
    Measure

    Pulse width against angle

    Students record the pulse width at 0, 45, 90, 135 and 180 degrees and plot it in the logbook.

  5. 1:4515 min
    Wrap-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.