Week 5 · Analogue, PWM & Task A

Session 23: PWM output and the oscilloscope

Teach & build120 minLesson 15: PWM Output & Duty Cycle

Learning outcomes

  • Explain duty cycle and why PWM is not a true analogue voltage
  • Use analogWrite on the ~ pins with values from 0 to 255
  • Measure PWM frequency and duty cycle on the oscilloscope
  • Map a potentiometer reading to LED brightness

Kit and components

  • Uno, LED and 330 Ω resistor, 10 kΩ potentiometer, breadboard
  • Oscilloscope and multimeter

Pre-reading about 25 min

Students read these on their phones before class. They are listed on the student Before class page.

  1. Lesson 15: What PWM is
  2. Lesson 15: analogWrite on the Uno
  3. Lesson 15: See PWM on the oscilloscope
  4. Theory Reference: map() and constrain()

Session plan

  1. 0:0010 min
    Recap

    Quiz: the ADC

  2. 0:1020 min
    Demo

    Duty cycle on the scope

    Show analogWrite(9, 127) on the scope and the meter at the same time: a 490 Hz square wave on one, 2.5 V on the other.

  3. 0:3035 min
    Measure

    analogWrite values on the scope

    Students fill in the lesson's table for 0, 64, 127, 191 and 255 - measured frequency, duty and multimeter average - then compare pin 9 with pin 6.

  4. 1:0545 min
  5. 1:5010 min
    Wrap-up

    Task A preview

    Hand out the Task A brief for students to read before S24.

Checkpoint: ready to move on?

Each student has a duty-cycle table with measured values, and their potentiometer smoothly controls the LED.

Extension for fast finishers

Two LEDs with opposite brightness on pins 9 and 6 (lesson challenge).

Catch-up path

Measure only 0, 127 and 255, concentrating on reading duty from the scope.

Homework and practice

Read the Task A brief and draft success criteria; Code Along 11.4.

Facilitator notes

  • Task A asks for the LOW speed's 40 % duty to be measured on the scope - this session's table is the practice.