Chapters

17 Visual and Audio Actuators: Displays and Buzzers

actuators
visual
audio

17.1 Start With the Decision

This section: Start With the Decision — An OLED is a screen made of tiny lights.

An OLED is a screen made of tiny lights. It can show rich detail but uses memory and a shared bus, a set of wires that several devices use. I2C is the two-wire bus used here. A buzzer makes a sound cue that works when no one is looking at the screen.

17.2 Route Overview

This section: Route Overview — This is part 2 of 2.

This is part 2 of 2. Review Visual and Audio Actuators: LED Feedback for the preceding evidence.

17.3 Learning Objectives

This section: Learning Objectives

  • Estimate OLED memory, power, and I2C needs.
  • Set buzzer tone and pattern for distinct alerts.

17.4 Chapter Roadmap

This section: Chapter Roadmap

  • OLED Displays
  • Try It: OLED Display Memory and Power Estimator
  • Checkpoint: Displays
  • Buzzers and Tone Generation
  • Musical Note Frequency Reference
  • Try It: Buzzer Alert Pattern Designer
  • Display Selection Guide
  • Bedside Feedback Actuators
  • Checkpoint: Alert Selection
  • Knowledge Check
  • Key Takeaway
  • For Kids: Meet the Actuator Crew!
  • Knowledge Check
  • Quiz: Visual and Audio Actuators
  • Match: Visual and Audio Actuator Concepts
  • Order: Steps to Control LED Brightness with PWM on ESP32
  • Label the Diagram
  • Code Challenge
  • Deep Dive: Feedback Loads, Perception, and Timed LEDs
  • Summary
  • Common Pitfalls
  • 1. LED Without Current Limiting Resistor
  • 2. Passive Buzzer Driven by DC Instead of Oscillating Signal
  • 3. Driving High-Current LED Strips Directly from MCU GPIO
  • 4. Active Buzzer and Passive Buzzer Confusion
  • What’s Next?

17.5 OLED Displays

This section: OLED Displays — OLED displays offer high contrast and graphical control in a compact panel.

OLED displays offer high contrast and graphical control in a compact panel. Inspect Figure 17.2 to connect that visual flexibility to the module’s power and I2C wiring before choosing it over a character display.

A small blue OLED module wired to an Arduino Nano and displaying text
Figure 17.2: A compact OLED module provides a high-contrast local display while using only a few signal and power wires -- the same SSD1306-class hardware driven by the code below. Photo: Turbospok, CC BY-SA 4.0

In Figure 17.2, start with the lit pixel area, then follow the few wires back to the controller board. The SSD1306 code below owns pixel placement rather than character cells, increasing information density while also making refresh strategy, readability, and display-on energy part of the interface decision.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextColor(SSD1306_WHITE);
}

void loop() {
  // Display sensor readings
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(0, 0);
  display.print("IoT Data");

  display.setTextSize(1);
  display.setCursor(0, 20);
  display.print("Temp: 25.4 C");
  display.setCursor(0, 35);
  display.print("Humid: 65.2 %");
  display.display();
  delay(2000);

  // Draw a progress bar
  for (int pct = 0; pct <= 100; pct += 2) {
    display.clearDisplay();
    display.setCursor(0, 10);
    display.print("Loading...");
    display.drawRect(10, 30, 108, 10, SSD1306_WHITE);
    display.fillRect(12, 32, pct, 6, SSD1306_WHITE);
    display.display();
    delay(40);
  }
}
Try It: OLED Display Memory and Power Estimator
Motor Max, Actuation and safe-control domain expertCheckpoint: Displays

You now know:

  • Character LCDs are layout-constrained: a 16x2 display only gives 16 columns per row before text is truncated.
  • OLED choices involve resolution, frame-buffer bytes, lit-pixel current, and interface speed.
  • A display is information-dense, but it only helps when someone is close enough and looking at it.

Visual feedback can show state quietly. The next section covers the output that interrupts attention.

17.6 Buzzers and Tone Generation

This section: Buzzers and Tone Generation

17.6.1 Passive Buzzer (Tone Generation)

Passive buzzers can play different frequencies/tones.

Calculate frequencies for musical notes and explore the relationship between pitch and frequency:

Common Notes for Buzzers:

  • C4 (Middle C): 262 Hz
  • A4 (Concert Pitch): 440 Hz
  • C5 (High C): 523 Hz
  • Alert tones typically use 1000-3000 Hz for maximum audibility
#define BUZZER_PIN 25

// Musical notes (frequencies in Hz)
#define NOTE_C4 262
#define NOTE_D4 294
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_G4 392
#define NOTE_A4 440
#define NOTE_B4 494
#define NOTE_C5 523

void setup() {
  pinMode(BUZZER_PIN, OUTPUT);
}

void loop() {
  playMelody();
  delay(2000);

  playAlarm();
  delay(2000);

  playNotification();
  delay(5000);
}

void playMelody() {
  int melody[] = {NOTE_C4, NOTE_E4, NOTE_G4, NOTE_C5};
  int durations[] = {250, 250, 250, 500};

  for (int i = 0; i < 4; i++) {
    tone(BUZZER_PIN, melody[i], durations[i]);
    delay(durations[i] * 1.3);  // Pause between notes
  }

  noTone(BUZZER_PIN);
}

void playAlarm() {
  for (int i = 0; i < 5; i++) {
    tone(BUZZER_PIN, 1000, 200);
    delay(250);
    tone(BUZZER_PIN, 500, 200);
    delay(250);
  }

  noTone(BUZZER_PIN);
}

void playNotification() {
  tone(BUZZER_PIN, NOTE_A4, 100);
  delay(150);
  tone(BUZZER_PIN, NOTE_C5, 200);
  delay(250);
  noTone(BUZZER_PIN);
}

17.6.2 Active Buzzer (Simple On/Off)

Active buzzers have built-in oscillators, so the controller supplies an on/off command rather than an audio-frequency waveform. Inspect Figure 17.3 to identify the simple two-lead load before comparing it with the passive tone() example.

Two round piezoelectric sounder discs lie side by side below a matchstick for scale. Their metallic central electrodes and outer rings are visible; neither disc has an attached wire lead or enclosing buzzer housing in this photo.
Figure 17.3: Two circular piezoelectric sounder elements are shown beside a match for scale. Their electrodes are visible, but no wire leads or built-in oscillator appear in this photo. Photo: me, CC BY-SA 3.0

In Figure 17.3, trace the two leads into the enclosed sounder and note that no external resonant drive circuit is visible. Applying rated power starts its internal oscillator and fixed tone; firmware controls timing and pattern, while a passive buzzer is required when pitch itself must carry information.

#define BUZZER_PIN 25

void setup() {
  pinMode(BUZZER_PIN, OUTPUT);
}

void beep(int count, int onTime, int offTime) {
  for (int i = 0; i < count; i++) {
    digitalWrite(BUZZER_PIN, HIGH);
    delay(onTime);
    digitalWrite(BUZZER_PIN, LOW);
    delay(offTime);
  }
}

void loop() {
  // Single beep
  beep(1, 100, 0);
  delay(2000);

  // Double beep
  beep(2, 100, 100);
  delay(2000);

  // Alarm pattern
  beep(5, 50, 50);
  delay(2000);
}
Try It: Buzzer Alert Pattern Designer

Buzzers add urgency, but they also add fatigue. The selection guide that follows treats sound as one channel in a larger feedback design, not as the default answer for every event.

17.7 Display Selection Guide

This section: Display Selection Guide — Choose a display by tracing the application’s dominant constraint across the table.

Choose a display by tracing the application’s dominant constraint across the table. Start with update rate and information density, then compare contrast in the actual lighting environment, and finally calculate energy over the real duty cycle rather than using active current alone. LCD or OLED fits frequent updates, e-paper fits long static intervals, and TFT earns its higher power only when colour graphics and rapid refresh materially serve the interface.

DisplayPowerContrastUpdate RateBest Use Case
16x2 LCD20-100mAMediumFastIndoor, mains powered
OLED10-50mAHighFastBattery, frequent updates
E-paper0.001mAHighestSlow (1s)Battery, infrequent updates
TFT LCD100-300mAMediumVery fastMains powered, graphics
Bedside Feedback Actuators

Scenario: A team is designing bedside monitors for a clinical ward. Each monitor tracks several patient readings and must draw staff attention to urgent conditions while avoiding constant, low-value beeping.

Constraints:

RequirementSpecificationWhy
Critical alarm responseImmediate local awarenessUrgent states should not depend on someone watching the display
Ambient noise levelVariable, with conversation and equipment noiseAudio must be noticeable without being constant
Night shift visibilityLow-light conditionsVisual cues essential
False alarm handlingSuppress nuisance alerts and escalate confirmed problemsPrevents alarm fatigue
Power budgetMains-powered (not a constraint)Hospital monitors plugged in

Actuator Selection Analysis:

Feedback ChannelComponent SelectedRationale
Critical alarm (audio)Passive buzzer or speaker with distinct tone patternsVariable frequency can distinguish alarm classes
Critical alarm (visual)Red strobe or high-visibility LED patternVisible when staff are not looking at the screen
Warning (audio)Shorter, quieter pulse patternDistinct from critical alarms and less fatiguing
Warning (visual)Amber LED steady glowVisible but non-urgent; amber = caution
Normal statusGreen LED steady“All OK” at a glance; no audio (reduces noise floor)
Detailed readingsOLED or LCD display sized for the enclosureHigh contrast and readable labels for local inspection
Nurse stationLarger graphical displayMultiple patients and alert states can be compared quickly

Why NOT these alternatives?

  • Active buzzer for all alarms: It is simple, but its fixed pitch makes it poor when different alarm classes need different sounds.
  • E-paper display at bedside: It is excellent for rare updates, but its slow refresh is a poor match for frequently changing waveforms.
  • Room-scale colored lighting: It can help in some spaces, but it requires building-level integration. A local high-visibility LED or strobe is simpler to verify.

Design Decision: Audio Pattern Differentiation

The system uses distinct alarm patterns so staff can identify urgency without first reading the screen:

Alarm TypeAudio PatternFrequencyPriority
Critical physiological alarmRepeating high-priority patternHigh pitch bandHighest
Urgent measurement alarmDescending or alternating patternMid/high pitch bandHigh
Device or sensor problemShort repeated pulsesMid pitch bandMedium
Low battery / sensor offOccasional single pulseLower pitch bandLow

Resulting design: Critical alarms use both a visual channel and an audio channel, warnings use lower-intensity patterns, and normal operation stays visual-only. That separation keeps urgent states noticeable while reducing unnecessary sound.

Motor Max, Actuation and safe-control domain expertCheckpoint: Alert Selection

You now know:

  • Passive buzzers need an audio-frequency waveform; active buzzers make their own fixed tone when powered.
  • Alert tones usually target 1000-3000 Hz, while lower tones around 500 Hz can be useful where hearing protection changes perception.
  • Critical states should use more than one channel when people may not be watching the device or may not hear it reliably.

17.8 Knowledge Check

This section: Knowledge Check

Key Takeaway

Visual and audio actuators provide essential user feedback in IoT systems. LEDs range from simple indicators to addressable strips capable of complex animations. Displays should be selected based on power budget (e-paper for battery, OLED for moderate updates, TFT for rich graphics). Passive buzzers offer flexible tone generation for alerts and melodies, while active buzzers provide simple on/off beeping. Always consider power consumption, as displays and LED strips can be the largest power consumers in a battery-powered IoT device.

“Time for the Output Show!” announced the LED, glowing all the colors of the rainbow. “We’re the actuators that you can SEE and HEAR!”

“Let me go first!” Lila said excitedly. She started dim, then slowly grew brighter and brighter. “Max controls my brightness with PWM — the same trick he uses for motors! But instead of spinning faster, I glow brighter!”

Then a whole strip of her NeoPixel friends lit up, each one a different color. “Meet my addressable friends! Even though there are 30 of us, Max only needs ONE wire to talk to all of us. The first pixel reads its color instruction, then passes the rest of the message down the chain — like a game of telephone, but it actually works perfectly!”

Next, Buzzy the Buzzer cleared his throat. “BEEP BOOP BEEEEP!” He played a little melody. “I’m a passive buzzer, which means Max can make me play ANY note by changing how fast he vibrates me. Higher frequency = higher pitch! I can even play songs!”

“And I’m the screen!” said OLED Olivia, displaying a smiley face. “I can show Sammy’s temperature readings, draw pictures, and even make progress bars. I use tiny organic light-emitting dots — each pixel makes its own light, so I’m super bright and clear!”

“We all work together,” said Temperature Terry. “I measure the temperature, Max decides what to do, and then Lila shows green for ‘all good,’ Olivia displays the number, and Buzzy beeps if it gets too hot. Input to output — that’s the IoT loop!”

the battery whispered, “Just remember, all those pretty lights use MY energy. Turn them off when nobody’s looking!”

17.9 Knowledge Check

This section: Knowledge Check

Quiz: Visual and Audio Actuators
Match: Visual and Audio Actuator Concepts
Order: Steps to Control LED Brightness with PWM on ESP32
Label the Diagram
Code Challenge

17.10 Deep Dive: Feedback Loads, Perception, and Timed LEDs

This section: Deep Dive: Feedback Loads, Perception, and Timed LEDs — Inspect Figure 17.1 before treating a status light as a purely visual choice.

Inspect Figure 17.1 before treating a status light as a purely visual choice. The panel encodes several user-facing states, while the companion circuit exposes the GPIO, resistor, LED, and return path that make each indication electrically safe.

Status indicator LED panel with power, Wi-Fi, data, sensor, error, and battery indicators beside a GPIO, resistor, LED, and ground return circuit.
Figure 17.1: Status indicator LED array with a current-limited GPIO LED circuit

Read Figure 17.1 from the named user states to the GPIO circuit. The panel decides what a person can distinguish; the resistor and return path decide whether the controller can drive the chosen LED safely. That pairing connects perception, timing, and electrical load rather than treating feedback as decoration.

LEDs, displays, and buzzers are simple only at the user interface. Electrically, each one still has a load path and a control signal. A small status LED shows the pattern: if a 3.3 V GPIO drives a red LED with about 2.0 V forward drop at 10 mA, the resistor must drop 1.3 V, so R = (3.3 - 2.0) / 0.010 = 130 ohms. Choosing 150 ohms gives I = 1.3 / 150 = 0.0087 A, or 8.7 mA. The resistor dissipates 1.3 V x 0.0087 A = 0.011 W, so a small signal resistor has margin. At 25% PWM duty cycle, the average LED current is about 8.7 mA x 0.25 = 2.2 mA.

The design decision is not only electrical. Feedback actuators differ in noticeability, power, and information density. A single green LED is excellent for a healthy status, but poor for a fault that must be noticed across a room. A display can show numbers and labels, but only helps when someone is looking at it. A buzzer interrupts attention, but repeated audio becomes annoying and may be masked by the environment. Strong products combine channels: quiet visual status for normal operation, stronger visual patterns for warnings, and audio only when the state needs immediate attention.

Displays need the same budget discipline. If a small OLED draws 20 mA from a 3.3 V rail while lit, the display load is 3.3 V x 0.020 A = 0.066 W. Left on for 24 hours, that is 0.066 W x 24 h = 1.58 Wh before regulator losses. On a small battery device, that can dominate the energy budget. If the value changes only occasionally, e-paper is often a better human interface because it can keep an image visible between refreshes without continuous display power.

Buzzers split into two kinds that are often confused. An active buzzer has an internal oscillator and produces one fixed tone when powered. A passive piezo or magnetic buzzer needs the controller to supply an audio-frequency waveform. A 2 kHz passive-buzzer alert has a period of 1 / 2000 = 0.0005 s, or 500 microseconds; a 50% square wave is high for about 250 microseconds and low for about 250 microseconds. A lower 500 Hz warning tone has a period of 1 / 500 = 0.002 s, or 2 ms. The controller changes pitch by changing the period, not by changing the supply voltage.

Addressable LEDs such as WS2812/NeoPixel parts add a different kind of timing constraint. Each pixel contains a driver chip, reads the first 24 bits as its green, red, and blue values, and forwards the rest downstream. There is no clock line; each bit is encoded by pulse width and lasts roughly 1.25 microseconds. A 30-pixel strip therefore needs 30 pixels x 24 bits = 720 bits, or 720 x 1.25 = 900 microseconds, plus the reset interval. An interrupt that pauses the GPIO waveform halfway through a bit can corrupt the data seen by every later pixel.

That timing issue is separate from the power issue. The same 30-pixel strip at full white can draw 30 x 60 mA = 1.8 A, which is 5 V x 1.8 A = 9 W. A microcontroller pin can generate the data waveform, but the 5 V supply and ground return must carry the power. Random flicker can come from data timing or from supply droop, so debug in order: limit brightness, confirm common ground, check the 5 V rail under load, then inspect whether the data driver can keep sub-microsecond timing without interruption.

17.11 Summary

This section: Summary — Visual and audio actuators transform digital data into human-perceivable feedback.

Visual and audio actuators transform digital data into human-perceivable feedback. Key concepts:

LED Control:

  • PWM dimming varies duty cycle (not voltage) to control perceived brightness
  • 8-bit PWM provides 256 brightness levels (0-255)
  • Power consumption scales linearly with duty cycle
  • RGB LEDs require three independent PWM channels

Addressable LED Strips:

  • WS2812B (NeoPixel) LEDs contain integrated driver chips
  • Single data wire controls hundreds of individually addressable pixels
  • Full white draws ~60mA per LED; single colors ~20mA
  • High current draws require external power supplies (not USB)

Displays:

  • LCD (16x2): Simple text, 20-100mA, ideal for mains-powered devices
  • OLED: High contrast, 10-50mA, battery-friendly with frequent updates
  • E-paper: Ultra-low power (0.001mA standby), slow refresh, best for infrequent updates
  • TFT LCD: Rich graphics, 100-300mA, requires mains power

Buzzers:

  • Passive: Requires frequency input, can play any tone/melody
  • Active: Built-in oscillator, simple ON/OFF control, fixed frequency
  • Alert tones: 1000-3000 Hz for maximum audibility
  • Low frequencies (~500 Hz) penetrate hearing protection better

Design Considerations:

  • Power budget is critical for battery-powered devices
  • Multi-modal feedback (visual + audio) improves critical alert perception
  • Distinct patterns prevent alarm fatigue in safety-critical applications
  • Standard resistor values (E12/E24 series) for current limiting

Common Pitfalls

This section: Common Pitfalls

An LED connected directly from VCC to GPIO (or directly to a supply) has no resistance to limit current. LED forward voltage (1.8-3.5 V) is much less than supply voltage (3.3-5 V). The excess voltage forces very high current through the LED, burning it out within seconds. Always calculate and install a current limiting resistor: R = (Vsupply - Vf) / If_desired.

A passive buzzer requires an oscillating signal (PWM at audio frequency) to produce sound — it is simply a piezo element that vibrates at the applied frequency. Applying a DC HIGH from a GPIO pin to a passive buzzer produces no sound (or a brief click as it deflects). Use analogWrite() or tone() with an audio-range frequency (1 kHz - 5 kHz) for audible output from passive buzzers.

WS2812B addressable LED strips draw up to 60 mA per RGB LED at full white brightness. A strip of 30 LEDs draws 1.8 A. A 30-pixel strip can draw about 1.8 A at full white, far beyond MCU GPIO power capability; use a separate 5 V supply rated above the strip’s worst-case current. Always power LED strips from a dedicated 5 V power supply rated for the full strip current, with a shared common ground to the MCU.

Active buzzers contain an internal oscillator and produce a fixed tone when voltage is applied (just connect VCC and GND). Passive buzzers require an external oscillating signal. They look identical externally and share the same package styles. Testing with a DC supply: active buzzers beep immediately; passive buzzers are silent. Apply the wrong driving method to the wrong buzzer type and you will get no sound.

17.12 What’s Next?

This section: What’s Next? — Now that you understand visual and audio actuators, explore related actuator types and deeper control techniques.

Now that you understand visual and audio actuators, explore related actuator types and deeper control techniques.

Next TopicDescription
PWM ControlDeeper dive into duty cycle calculations and waveform generation
DC MotorsSpeed and direction control using H-bridge drivers and PWM
Servo MotorsPrecise angular positioning with pulse-width control
Actuator SafetyFlyback protection, current limiting, and thermal management
Actuator ClassificationsSurvey of all actuator types and selection criteria

17.13 Continue Your Route

This section: Continue Your Route — This is the last part of this chapter.

This is the last part of this chapter. Return to Visual and Audio Actuators: LED Feedback or continue from the actuators module index.

Find help

3 reviewed answers.

Where should I start in a module?

Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.

Modules and paths

Reviewed

What can I try when a project does not work?

Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.

When you are stuck

Reviewed

How do interactive examples work?

Use the interactive guide to check how examples and simulations work before changing your project.

Interactive examples guide

Reviewed