Week 3 · Functions, Outputs & Buttons
Session 13: Digital outputs, RGB LEDs and buzzers
Learning outcomes
- Wire a common-cathode RGB LED with one resistor per colour
- Mix colours with digitalWrite
- Play tones on a passive buzzer with tone() and noTone()
- Measure a tone's frequency on the oscilloscope
Kit and components
- Uno, breadboard, common-cathode RGB LED, 3 × 330 Ω resistors, passive buzzer, jumpers
- Oscilloscope
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: functions
- 0:1020 minDemo
Three LEDs in one package
Show the RGB pinout, why each colour needs its own resistor, and the seven digitalWrite colours. Play a tone and show it on the scope.
- 0:3035 minBuild
RGB and buzzer circuit
Students wire the lesson circuit, upload the worked sketch and confirm on the scope that tone(6, 1000) gives a 1 ms period.
- 1:0545 minCode Along
Outputs, colour and sound
- 1:5010 minWrap-up
Active or passive?
Checkpoint: ready to move on?
Each student's RGB LED shows at least four colours from their own code, and they have measured a tone frequency on the scope.
Extension for fast finishers
Explain from the tone() entry why PWM on pins 3 and 11 stops while a tone plays.
- Code Along 6.6: Startup chimeDeeperLaptop
Catch-up path
If a colour is missing, check each leg and resistor with the meter in continuity mode (power off).
Homework and practice
Code Along 6.4 and 6.5.
Facilitator notes
- Some kits contain common-anode RGB LEDs, which invert the colours. The lesson's common cathode vs common anode section explains the fix.