Source: https://mokxi.com/parts/piezo
Updated: 2026-11-10

Part

# Piezo speaker

Makes whatever tone you drive it with, and shows it.

See every part

- 2 pins
- In 51 projects
- In 21 lessons

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Piezo speaker in brief

What it is, and where it sits on the bench.

A passive piezo element is a ceramic disc on a brass plate with two legs and no oscillator inside; that is what separates it from the near-identical active buzzer. A steady voltage does nothing; it sings whatever square wave it is given, so one leg goes to a digital pin and the other to ground, and tone() on an Uno or ESP32 picks the note, 440 Hz for an A. Mokxi’s part is a frequency counter on the voltage across its legs, counting a rise at 1.0 volt and a release at 0.4 volts so a slow or noisy edge cannot count twice, and it reports the note in hertz. Anything faster than 40 kHz is treated as noise, and 60 milliseconds without an edge reads as silence, so a very short blip never gets a frequency. The common mistake is wiring it like a buzzer, giving it plain DC and wondering why it is quiet. The disc’s roughly 10 nF of capacitance, its resonance near 4 kHz and its loudness are not modeled. You hear the note it plays through your computer’s speakers, as a soft square wave at that frequency.

Family

Outputs

Pins

2

Pins

## 2 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

1

One leg.

2

The other leg.

How to use it

## How to use a passive piezo with an Arduino

One leg goes to a digital pin and the other to GND, with no resistor. Then tone(pin, frequency) starts a square wave on the pin and returns at once, and noTone(pin) stops it, so the sketch decides how long each note lasts with its own delay(). Without tone(), a passive piezo on a pin held HIGH stays silent.

The circuit here plays the opening of Ode to Joy on pin 8, lights an LED on pin 13 for every note, and prints each pitch on the serial monitor. The 30 ms gap after every noTone() is what makes two notes of the same pitch sound like two notes rather than one long one, and the piezo’s readout shows the frequency it hears.

Part pin

Board pin

Leg 1

Pin 8

Leg 2

GND

tone() compiles for the ESP32 here too, and a 3.3 V square wave crosses the piezo’s 1 V threshold with room to spare.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

A tune with tone() and noTone()

How it is modeled

## What is true about the Piezo speaker, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The part watches the voltage across its two legs and times the transitions, with
hysteresis so a slow edge or a noisy net cannot count twice; the gap between one
rise and the next is the note's period, and the probe reports its frequency in
hertz. Driven differentially, as an H-bridge would, it reads the same way, because
what it is watching is the difference between the legs. Silence for long enough
reads back as 0 Hz.

### Not modeled

No capacitance (a real element is roughly 10 nF and loads the pin driving it; this
one is high impedance on both legs) and no loudness. The probe is a frequency, not
a volume. You hear the note it plays through your computer's speakers, as a square
wave at that frequency and a fixed soft level (the speaker button on the canvas
toolbar mutes it).

It is a frequency counter rather than an acoustic model. The hysteresis is 1.0 V to go
one way and 0.4 V to come back, which are round numbers rather than a real element's
thresholds, and they are absolute volts: a 3.3 V board's square wave crosses them and a
200 mV signal never does, however loud a real disc would be. Anything faster than
40 kHz is rejected as noise rather than reported, and 60 ms with no edge reads as
silence, so a note shorter than that never gets a frequency at all. There is no
resonance (a real disc is loudest near 4 kHz and nearly silent an octave away), no
mechanical ring-down, no harmonics and no waveform: a sine and a square at the same
rate read identically.

From Piezo element (passive), in full.

Projects

## See the Piezo speaker in a project

51 built-in projects use it. Each opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

21 lessons place it in their own circuits.

### The twelve week course

1 lesson

- Week 11: Interrupts: events instead of polling

### Learn articles

20 lessons

- The 555 Astable: Timed by a Capacitor, Not a Crystal
- Arduino Buzzer and Piezo: Beeps, Notes, Metronome
- Arduino Science Fair Projects With a Real Hypothesis
- Reaction Time Science Fair Project With an Arduino
- Arduino while Loop: Wait, Repeat, Break Out
- Arduino enum: Named States, enum class and Switch
- Arduino Model Railroad: Turnouts, Crossings, Signals
- Arduino ILI9341 TFT Display: Wiring and Code
- Arduino Tone Melody: Play a Song on a Piezo
- Arduino TM1637 Display: Library and Countdown
- Arduino DS1302 RTC: an Alarm Clock With Code
- Arduino MLX90614: Non-Contact IR Thermometer
- Arduino MPR121: 12-Key Capacitive Touch Piano
- Free Arduino Simulator for Students, in the Browser
- Arduino Practical Exam Practice: Ten Timed Tasks
- Arduino Holiday Projects for Every Celebration
- Arduino Whack-a-Mole Game: LEDs, Buttons, Score
- Arduino Game Projects You Can Play in Your Browser
- STEM Club Ideas: Electronics and Coding Sessions
- Wokwi Alternatives for Arduino and ESP32, Compared

Boards

## The boards it is shown on

Each of these 3 boards has a built-in project with the Piezo speaker in it.

- Arduino Uno R3
- ESP32-C3-DevKitM-1
- Arduino Mega 2560

Boards

## The Piezo speaker on each board

The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.

- Arduino Uno and Buzzer
- ESP32 and Buzzer
- Arduino Nano and Buzzer
- ESP32-C3 and Buzzer
- ESP32-S3 and Buzzer
- Raspberry Pi Pico and Buzzer
- Arduino Uno R4 and Buzzer

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Piezo speaker

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
