Piezo Buzzer

A two-terminal passive piezo buzzer that turns a square wave into audible tones and alerts.

  • Supply voltage5 V
  • Maximum supply voltage12 V
  • Dimensions12 × 12 × 8.5 mm
Piezo Buzzer, A two-terminal passive piezo buzzer that turns a square wave into audible tones and alerts.
In short

A passive piezo buzzer is a two-pin piezoelectric sounder with no oscillator inside: it only sounds when you feed it a square wave, and the wave's frequency sets the pitch. Wire + through a 100 Ω resistor to any digital pin and - to GND, then call tone(pin, frequency); a typical 12 mm part such as TDK's PS1240P02BT is loudest near 4 kHz, at 70 dB(A) at 10 cm from a 3 V square wave (TDK PS series datasheet, p.4).

The piezo buzzer is a compact sounder that converts an electrical signal into sound with a piezoelectric ceramic element. It has two terminals, + (signal) and - (GND), and a typical 12 mm part such as TDK's PS1240P02BT measures 12.2 mm across and 6.5 mm high, small enough for a breadboard or a panel.

This is a passive piezo element: it has no internal oscillator and makes no sound from steady DC. You feed the + pin a square wave, and the frequency of that wave sets the pitch. On Arduino the tone() function generates the waveform for you, so you can play beeps, alarms or melodies. A piezo is loudest near its resonant frequency; TDK rates the PS1240P02BT at 4 kHz, where it gives at least 70 dB(A) at 10 cm from a 3 V peak square wave.

Electrically the element behaves like a small capacitor, so it takes current only on each edge of the wave. A small series resistor limits those edge currents, and with it the buzzer runs straight from a microcontroller pin, no transistor needed. That makes it a go-to part for keypress clicks, low-battery warnings, timer alarms, proximity alerts and simple tunes.

How to wire the Piezo Buzzer

Pin by pin, for the board you have.

Piezo BuzzerArduino UnoNote
plusD2through a 100 Ω resistor
minusGND
Open this circuit on an Arduino Uno

Before you wire it

Do
  • Component is polarized: plus (+) to signal, minus (-) to GND
  • Use tone(pin, frequency) for the pitch (noTone(pin) to stop): works on any digital pin
  • Any digital pin works. tone() borrows a shared timing resource, so it costs PWM elsewhere: on AVR it takes Timer2, killing PWM on D3/D11 (Uno) or D9/D10 (Mega); on ESP32 it takes one LEDC channel, of which the S3 has only 8. See protocols/pwm.md.
  • Series resistor (100Ω) required between Arduino digital pin and buzzer (+). The piezo element is capacitive (~20 nF); without the resistor, the inrush current spikes during PWM transitions can exceed the 20 mA GPIO limit.
Don’t
  • Do not reverse polarity (plus and minus)
  • Do not expect digitalWrite(HIGH) to sound it: that is the active buzzer (buzzer-active)
  • Do not use analogWrite() for buzzer: use tone() instead
  • Wire + (signal) through a 100 Ω series resistor to the driving pin and - (GND) to the board's ground. The studio requires the resistor: the element is capacitive, and without it the current spike on each edge can exceed the pin's limit.
  • Drive a passive piezo with an alternating signal, not steady DC. Use tone() or a square wave; holding the pin HIGH gives at most a single click.
  • Keep the + side on the signal and the - side on ground, as marked.
  • For more volume, switch the buzzer with an NPN transistor or small MOSFET from a higher supply and keep that supply's ground common with the microcontroller. TDK's PS1240P02BT accepts up to 30 V peak without DC bias.
  • On the Arduino Uno, tone() uses Timer2, so it interferes with analogWrite() (PWM) on pins 3 and 11 while a tone plays.

Specifications

Supply voltage
5 V
Maximum supply voltage
12 V
Dimensions
12 × 12 × 8.5 mm

Common mistakes

  1. Using digitalWrite HIGH instead of tone()

    A passive piezo needs an oscillating signal. Setting the pin permanently HIGH charges the element once and you hear only a faint click. Use tone(pin, frequency) to get a sustained sound.

  2. Confusing a passive piezo with an active buzzer

    An active buzzer has a built-in oscillator and beeps at one fixed pitch whenever it gets DC. This passive piezo has none: it stays silent on DC but plays any pitch you feed it. Active-buzzer code (plain HIGH/LOW) gives no tone on a passive part.

  3. Trying to set pitch with analogWrite()

    analogWrite() outputs PWM at a fixed frequency (490 Hz on most Uno pins, 980 Hz on pins 5 and 6) and only varies the duty cycle, so it cannot change the note. Use tone() to set the frequency.

  4. Leaving out the series resistor

    The piezo is a capacitive load, so every edge of the square wave is a brief current spike out of the pin. The studio puts 100 Ω in series with + to keep those spikes within the GPIO limit.

  5. Forgetting tone() blocks PWM on pins 3 and 11

    On the Uno, tone() takes Timer2, which also generates PWM on pins 3 and 11. If you dim an LED or drive a motor on those pins, tone() disrupts them until noTone() is called.

Piezo Buzzer questions

How do I connect a passive piezo buzzer to an Arduino?

Connect + through a 100 Ω resistor to any digital pin and - to GND, then call tone(pin, 1000) for a 1 kHz beep and noTone(pin) to stop. tone() works on any digital pin.

What is the difference between a passive and an active buzzer?

An active buzzer has its own oscillator and sounds one fixed pitch as soon as it gets DC, so digitalWrite(HIGH) is enough. A passive piezo has no oscillator: it needs a square wave from tone(), but it can play any pitch, which is what melodies need.

Why does my piezo buzzer only click?

It is being driven with DC. A passive piezo makes sound only from an alternating signal, so digitalWrite(HIGH) gives one click as the element charges. Use tone(pin, frequency) instead, and check that the pin you pass is the one wired to +.

Can I use a piezo buzzer with an ESP32 or other 3.3V board?

Yes. tone() works on the ESP32 core and on the Pico, and a 3.3 V square wave is enough to drive a small piezo: TDK specifies the PS1240P02BT's sound pressure at a 3 V peak square wave (TDK PS series datasheet, p.4). On the ESP32 each tone takes an LEDC channel.

What frequency is a piezo buzzer loudest at?

At its resonant frequency, which depends on the part: TDK's 12 mm PS1240P02BT is rated at 4 kHz, where it gives at least 70 dB(A) at 10 cm (TDK PS series datasheet, p.4). For a loud alarm, sweep a few kilohertz and keep the frequency that sounds loudest.

How can I make a piezo buzzer louder?

Play it near its resonant frequency and drive it with a higher voltage swing: switch it with a transistor from a higher supply, keeping grounds common. TDK's PS1240P02BT is rated for up to 30 V peak without DC bias (TDK PS series datasheet, p.4).

Build something with the Piezo Buzzer

  • Melody and ringtone player

    Use tone() with an array of note frequencies and durations to play songs, jingles or startup chimes from a single output pin.

    Build this
  • Ultrasonic distance alarm

    Pair the buzzer with an HC-SR04 sensor and beep faster as an object gets closer, a classic parking or proximity warning.

    Build this
  • Countdown and kitchen timer

    Sound an alarm pattern when a timer reaches zero, with a button to start and an LCD or 7-segment display for the countdown.

    Build this
  • Reaction-time game

    Flash an LED, start a millis() timer, and buzz when the player presses too early or reacts, scoring their response speed.

    Build this
  • Keypad and UI feedback beeps

    Add a short confirmation beep on each button or keypad press and a distinct error tone for invalid input.

    Build this
For AI assistants

This page as plain Markdown, for ChatGPT, Claude or your own agent. /components/piezo-buzzer.md

What will you build with it?