Week 5 · Analogue, PWM & Task A
Session 23: PWM output and the oscilloscope
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.
Session plan
- 0:0010 minRecap
Quiz: the ADC
- 0:1020 minDemo
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.
- 0:3035 minMeasure
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.
- 1:0545 min
- 1:5010 minWrap-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).
- Code Along 11.6: Fade without blockingDeeperLaptop
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.