Part

Buzzer

Sounds when it is driven, and shows it on screen.

See every part
  • 2 pins
  • In 17 projects
  • In 9 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Buzzer in brief

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

Mokxi models the ordinary small piezo buzzer that most kits ship, the active kind with its own oscillator built in, rather than a bare speaker element. Electrically it behaves like a polarized resistor: it conducts, and sounds, only while its longer leg sits above its shorter one, and it goes high-impedance the moment it is reverse biased or left with either leg floating. There is no audio waveform in the model, only a sounding-or-not state and the current it draws while it does, which is enough to show the one mistake almost everyone makes with this part: put the usual 220 ohm "LED resistor" in series with it and the divider that results leaves too little voltage across the buzzer to sound at all, so it goes silent rather than merely quieter. People wiring a buzzer for the first time often assume it has failed; here the same current probe that explains an LED’s brightness explains why the buzzer has gone quiet instead.

Family
Outputs
Pins
2

A circuit built around it, running and explained: the Buzzer simulator.

Pins

2 pins

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

Pin
What it does
1
The longer leg, positive.
2
The shorter leg, negative.
How to use it

How to use an active buzzer with an Arduino

An active buzzer has its oscillator built in, so it needs no tone() and no square wave: put DC across it the right way around and it sounds its one note. The longer leg is positive and goes to a digital pin; the shorter leg goes to GND. Then digitalWrite(pin, HIGH) starts it and LOW stops it.

It draws about 30 mA at 5 V, inside what an Uno pin can give, so the door alarm here drives it straight from pin 8, with no resistor: a 220 ohm resistor in series, the usual LED value, would leave too little voltage across it to sound. Open the door, by moving the magnet away from the reed switch, and the buzzer and a lamp latch on until the button resets them.

Part pin
Board pin
Positive (pin 1, longer leg)
Pin 8
Negative (pin 2, shorter leg)
GND

For melodies use a passive piezo instead, which needs tone(): the buzzer pages for each board, listed further down, play a tune that way. On a 3.3 V board, a 5 V active buzzer may be too quiet straight off a pin; switch it with a transistor from 5 V.

Arduino Uno: door alarmlive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
Sounding an active buzzer
const int BUZZER = 8;

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

void loop() {
  digitalWrite(BUZZER, HIGH);   // it makes its own note
  delay(200);
  digitalWrite(BUZZER, LOW);
  delay(800);
}
How it is modeled

What is true about the Buzzer, here

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

Modeled

The buzzer really loads the net it is on, the same way the LED does, and that matters for a common mistake: driven straight off a 5 V rail it takes about 31 mA and sounds, but with the usual "LED resistor" of 220 ohms in series, the divider it forms leaves only around 2 V across it (below the threshold it needs), so it goes silent rather than merely fainter.

Not modeled

No audio waveform and no volume. You hear a steady tone near 2.3 kHz through your computer's speakers while it sounds (the speaker button on the canvas toolbar mutes it), but the probe reports sounding or not sounding, nothing in between, and no reverse current or capacitance either.

The two numbers behind that are both round rather than measured from one part. The element is a plain 160 ohm resistor while it conducts, which is the round number next to the 167 ohms a 12 mm 5 V buzzer's rated 30 mA at 5 V works out at, so it draws 31 mA on a stiff rail. It is called sounding at 2.5 V across it and silent below, which is half the rated supply and stands in for the 3 V to 8 V operating range those datasheets quote. A real buzzer fades out over a volt or so rather than stopping at a line. There is no frequency at all: a real active buzzer's note is somewhere near 2.3 kHz and this part has none.

From Buzzer (active), in full.

Projects

See the Buzzer in a project

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

Boards

The boards it is shown on

This board has a built-in project with the Buzzer in it.

Wire up the Buzzer

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