Week 3 · Functions, Outputs & Buttons

Session 13: Digital outputs, RGB LEDs and buzzers

Teach & build120 minLesson 09: Digital Outputs, RGB LEDs & 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.

  1. Lesson 09: Safe loads vs drivers
  2. Lesson 09: RGB LEDs: three dies, three resistors
  3. Lesson 09: Active vs passive buzzers
  4. Theory Reference: tone() and noTone()

Session plan

  1. 0:0010 min
    Recap

    Quiz: functions

  2. 0:1020 min
    Demo

    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.

  3. 0:3035 min
    Build

    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.

  4. 1:0545 min
  5. 1:5010 min
    Wrap-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.

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.