Submit

05 / 20

Sound a siren

Sweep a passive buzzer between two frequencies.

Run this experiment →
ESP32 teaching illustration with module, GPIO headers and lesson components

Why it’s here

Set the low and high tones, enable audio, and listen to the sweep.

How it works

Sweep a passive buzzer between two frequencies. The pitch rises. Frequency is measured in hertz; loudness is a separate property. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.

Try it

  1. Open this experiment
  2. Set the low and high tones, enable audio, and listen to the sweep.

Connections

  • GPIO 25 / GND — Passive buzzer

Example sketch

void setup() {
  ledcAttach(25, 1000, 8);
}

void loop() {
  float phase = (millis() % 2000) / 2000.0f;
  float sweep = 1 - abs(2 * phase - 1);
  ledcWriteTone(25, 440 + sweep * (880 - 440));
}

Check your understanding

What does a higher frequency change?

Show the answer

The pitch rises. Frequency is measured in hertz; loudness is a separate property.

Sources

Arduino-ESP32 ↗ · GPIO reference ↗

MAKE A THOUGHTFUL CHOICE

Your shortlist, side by side.

Pricing models are indicative. Check each official website for current plans and limits.