An active buzzer is the simplest way to make a project beep. Apply its rated voltage and it sounds; remove the voltage and it stops. There is no frequency to generate and no library to install, because the part contains its own oscillator circuit that drives the sound element at a fixed tone, usually around 2.3 kHz. That makes it ideal for alarms, button feedback, timers and "something went wrong" warnings.
The word active refers to that built-in drive circuit. A passive buzzer looks almost identical but has no oscillator: it is just a sound element, and your microcontroller has to switch it on and off thousands of times a second (for example with tone()) to make a sound. Passive buzzers can play melodies; active buzzers play one note, loudly and with almost no code.
Active Buzzer at a glance
Active buzzer in one paragraph. Built-in oscillator, one fixed tone (about 2.3 kHz), typically 5 V and up to 30 mA, 85 dB or more at 10 cm. It is polarised: the longer lead or the "+" mark goes to positive. A bare buzzer draws more than an Arduino pin should supply continuously, so drive it with a small NPN transistor, or use a three-pin module that already has one. Some modules sound when the signal pin is LOW, so test yours before writing your logic.
Specifications
- Type
- Magnetic or piezo sounder with a built-in oscillator
- Rated voltage
- 5 V (3 V and 12 V versions also exist)
- Operating voltage
- About 4–8 V for typical 5 V parts (some are rated 3–7 V)
- Current
- Up to 30 mA at rated voltage
- Sound output
- 85 dB or more at 10 cm
- Tone
- Fixed, about 2.3 kHz ± 300 Hz (varies by part)
- Size
- 12 mm diameter, about 9 mm tall
- Polarity
- Yes: longer lead or + marking is positive
- Operating temperature
- About −20 to +70 °C
Typical figures for 12 mm 5 V active buzzers from manufacturer datasheets (for example the LTE12-05 and PUI Audio AI-1223-TWT-5V). Check the markings and listing for your part.
Pinout
| Pin | Name | Description |
|---|---|---|
| + | Positive | Longer lead, or the leg next to the + mark on top. Connect to the supply or the driver. |
| − | Negative | Shorter lead. Connect to ground or to the transistor's collector. |
Polarity matters. An active buzzer's oscillator is a small circuit, and connected backwards it will stay silent. On many parts the protective sticker on top also carries the + mark. Remove the sticker before use; it is there for the soldering process and muffles the sound.
Three-pin buzzer modules
| Pin | Label | Function |
|---|---|---|
| VCC | + or VCC | Module supply, usually 3.3–5 V |
| I/O | S, SIG or I/O | Control input from a microcontroller pin |
| GND | − or GND | Ground |
Three-pin modules add a transistor and a resistor, so the signal pin only has to supply a tiny base current. Two designs are common. Modules with an NPN transistor sound when the signal is HIGH. Modules with a PNP transistor, often an S8550, sound when the signal is LOW and stay silent when it is HIGH. Pin order also varies between makers, so follow the printed labels.
How an active buzzer works
Inside the case is a sound element and a tiny oscillator circuit. In a magnetic buzzer, the oscillator switches a coil on and off, and the coil pulls a thin metal diaphragm back and forth. In a piezo buzzer, the oscillator applies an alternating voltage to a ceramic disc that flexes with each change. Either way, the diaphragm vibrates at the oscillator's frequency, and the case is shaped to resonate at that frequency and make it loud.
Because the frequency is set inside the part, you only control when it sounds. Turning the power on and off in patterns (short chirps, long tones, fast pulses) is how you give different signals different meanings.
Active or passive? Three ways to tell
- Look underneath. Active buzzers usually have a sealed black bottom. Passive buzzers often show a green circuit board or bare coil.
- Apply 5 V briefly (through a 100 Ω resistor to be safe). An active buzzer gives a continuous tone. A passive buzzer only clicks once.
- Measure resistance. Many small magnetic passive buzzers read a low, steady coil resistance, often around 16 Ω. An active buzzer does not show a simple coil resistance because of its internal circuit.
Active vs passive buzzers
Active buzzer
- Drive signal
- Steady DC on/off
- Sound
- One fixed tone, loud
- Code needed
- digitalWrite()
- Best for
- Alarms, beeps, warnings
Passive buzzer
- Drive signal
- Square wave (e.g. tone())
- Sound
- Any pitch, melodies
- Code needed
- tone() or PWM
- Best for
- Tunes, multi-tone alerts
Active buzzer module
- Drive signal
- Logic signal (active HIGH or LOW)
- Sound
- One fixed tone
- Code needed
- digitalWrite()
- Best for
- Plug-and-play beeping
Calling tone() on an active buzzer does not change its pitch; it just chops the built-in tone and produces a rough rattle. Use a passive buzzer when you need different notes.
Driving it safely from a microcontroller
An Arduino Uno pin is rated for 40 mA absolute maximum, with 20 mA recommended for continuous use. A 5 V active buzzer can draw up to 30 mA, so connecting it straight to a pin may work but runs the pin harder than it should. An ESP32 pin is weaker still and only provides 3.3 V, which makes many 5 V buzzers quiet or unreliable.
The fix is a small NPN transistor used as a low-side switch:
- Buzzer + to 5 V, buzzer − to the transistor's collector.
- Transistor emitter to GND.
- Microcontroller pin to the transistor's base through a 1 kΩ resistor.
- Optional: a 1N4148 diode across the buzzer (cathode to 5 V) to absorb voltage spikes from a magnetic buzzer's coil.
Any small NPN works: 2N2222, BC547, 2N3904 or S8050. The pin now supplies only a few milliamps, the buzzer gets a full 5 V, and the same circuit works on 3.3 V boards such as the ESP32.
Ready to build?
- Active buzzer with Arduino Uno: the transistor driver, beep patterns you can trigger from the Serial Monitor, and how to handle active-LOW modules.
- Active buzzer with ESP32: 3.3 V logic driving a 5 V buzzer, boot-safe pin choice and a non-blocking beeper that never stalls your code.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Silent | Reversed polarity, or it is actually a passive buzzer | Check the + lead; test with 5 V through 100 Ω: a single click means passive |
| Beeps constantly from power-up and stops when you send HIGH | Active-LOW module (PNP transistor) | Invert the logic: LOW = on, HIGH = off |
| Very quiet on an ESP32 | 5 V buzzer driven from a 3.3 V pin | Use the NPN driver and power the buzzer from 5 V |
| Rough rattling sound | tone() used on an active buzzer | Use digitalWrite() HIGH and LOW |
| Chirps when the ESP32 boots | Buzzer on a pin that toggles during boot | Move it to a pin such as GPIO25, 26 or 27 |
| Arduino resets when it beeps | Weak USB supply, or buzzer on 5 V without decoupling | Add 100 µF across 5 V and GND near the buzzer |
| Sound is muffled | Protective sticker still on | Peel off the sticker |
What to build with it
- Door or drawer alarm with a reed switch and a magnet.
- Parking sensor with an HC-SR04: beep faster as an object gets closer.
- Kitchen or study timer with a button and a display.
- Keypad feedback: a 30 ms chirp on every key press makes a project feel finished.
- Temperature or gas alarm that sounds when a sensor crosses a threshold.
Frequently asked questions
Can I change the pitch of an active buzzer? No. The tone is set by its internal oscillator. Use a passive buzzer for different notes.
Can I connect it straight to an Arduino pin? A 5 V buzzer drawing 20 mA or less will work, but up to 30 mA exceeds the recommended pin current. A transistor or a module is the reliable choice.
Why does my module beep when the pin is LOW? It uses a PNP transistor and is active-LOW. Write HIGH to keep it quiet.
Can I make it quieter? Leave the sticker on, add a resistor of about 100 Ω in series, or use short chirps. Volume changes are limited because the built-in oscillator needs enough voltage to run.
Will a 5 V buzzer work at 3.3 V? Some do, more quietly; others will not start. Drive it from 5 V through a transistor, or buy a 3 V buzzer.
Datasheets and references
- Manufacturer datasheets for 12 mm active buzzers (for example the LTE12 series and PUI Audio AI-1223-TWT-5V): voltage, current, sound level and frequency ranges used on this page.
- Microchip ATmega328P datasheet: I/O pin current ratings.
Wiring & code
Board integration
In this guide you will connect an active buzzer to an Arduino Uno and make it beep in different patterns: a start-up chirp, a short confirmation beep, a long tone and an alarm, each triggered by typing a letter in the Serial Monitor. You will also see how to drive a bare buzzer safely with a transistor, how to handle modules that beep when the pin is LOW, and how to beep without freezing the rest of your sketch.
What you need
Arduino Uno (R3 or R4) and USB cable
- Quantity
- 1
- Note
- Any Uno-compatible board works
Active buzzer, 5 V
- Quantity
- 1
- Note
- Bare 2-lead buzzer or a 3-pin module
NPN transistor (2N2222, BC547, 2N3904 or S8050)
- Quantity
- 1
- Note
- Only for a bare buzzer
1 kΩ resistor
- Quantity
- 1
- Note
- Base resistor for the transistor
1N4148 diode
- Quantity
- 1
- Note
- Optional, recommended for magnetic buzzers
Breadboard and jumper wires
- Quantity
- -
Option A: three-pin buzzer module
A module already contains a transistor, so you can connect it directly. This is the quickest way to get started.
Wiring: buzzer module
| Module pin | Arduino Uno pin | Note |
|---|---|---|
| VCC (+) | 5V | Module supply |
| I/O (S) | D8 | Control signal |
| GND (−) | GND | Common ground |
Option B: bare buzzer with an NPN transistor
A bare buzzer can draw up to 30 mA, more than the 20 mA an Uno pin should supply continuously. A small NPN transistor does the heavy lifting while the pin only supplies about 4 mA through the base resistor.
Wiring: bare buzzer and transistor
| Circuit point | Connect to | Note |
|---|---|---|
| Buzzer + | Uno 5V | Longer lead / + mark |
| Buzzer − | Transistor collector | The transistor switches the buzzer's ground side |
| Transistor emitter | Uno GND | |
| Transistor base | Uno D8 through 1 kΩ | Never connect the base directly to the pin |
| 1N4148 diode | Across the buzzer | Stripe (cathode) to 5V; optional |
Tip
Check your transistor's pin order. A 2N2222 or 2N3904 in a TO-92 package reads E, B, C with the flat face towards you, but the BC547 is C, B, E. Look up the part printed on yours before wiring.
- 1Open the Arduino IDE (version 2.x recommended). No extra library is needed.
- 2Plug in the Uno, then choose Tools → Board → Arduino Uno and select its port under Tools → Port.
- 3Paste the sketch below and click Upload.
- 4Open Tools → Serial Monitor and set it to 9600 baud.
- 5You should hear two short chirps. Type
s,loraand press Enter to hear each pattern.
// Active buzzer on an Arduino Uno - SolderHub
// Works with a bare buzzer on an NPN driver, or with a 3-pin module.
const int BUZZER_PIN = 8;
const bool ACTIVE_LOW = false; // set to true if your module beeps when the pin is LOW
void buzzerOn() { digitalWrite(BUZZER_PIN, ACTIVE_LOW ? LOW : HIGH); }
void buzzerOff() { digitalWrite(BUZZER_PIN, ACTIVE_LOW ? HIGH : LOW); }
// Beep `count` times: on for onMs, off for offMs.
void beep(unsigned int onMs, unsigned int offMs, byte count) {
for (byte i = 0; i < count; i++) {
buzzerOn();
delay(onMs);
buzzerOff();
delay(offMs);
}
}
void setup() {
buzzerOff(); // set the idle level before the pin becomes an output
pinMode(BUZZER_PIN, OUTPUT);
buzzerOff();
Serial.begin(9600);
beep(100, 100, 2); // two short "ready" chirps
Serial.println(F("Buzzer ready. Type s = short, l = long, a = alarm"));
}
void loop() {
if (Serial.available()) {
char c = Serial.read();
if (c == 's') { beep(80, 80, 1); Serial.println(F("short beep")); }
if (c == 'l') { beep(600, 100, 1); Serial.println(F("long beep")); }
if (c == 'a') { beep(150, 150, 10); Serial.println(F("alarm")); }
}
}How the code works
BUZZER_PINis the Uno pin connected to the module's I/O pin or the transistor's base resistor.ACTIVE_LOWhandles both kinds of module. NPN-based modules and the transistor circuit sound on HIGH. Many three-pin modules use a PNP transistor and sound on LOW; set this totruefor those.buzzerOn()andbuzzerOff()hide the difference from the rest of the code.- In
setup(),buzzerOff()runs beforepinMode(). For an active-LOW module this sets the pin HIGH first, so the buzzer does not give a stray beep the moment the pin becomes an output. beep(onMs, offMs, count)turns the buzzer on and off a number of times. Because an active buzzer has its own oscillator,digitalWrite()is all it needs; notone()call.- In
loop(), the sketch reads one character from the Serial Monitor and plays the matching pattern.F("...")keeps the text in flash memory instead of the Uno's small RAM.
Expected output
Right after upload you hear two quick chirps and the Serial Monitor shows:
Buzzer ready. Type s = short, l = long, a = alarmTyping s gives a short beep, l a long tone and a ten fast beeps, each confirmed with a line in the Serial Monitor. If the buzzer sounds continuously from power-up and goes quiet when it should beep, your module is active-LOW: set ACTIVE_LOW to true and upload again.
Going further: beep without blocking
delay() is fine for a demo, but it freezes the Uno while it waits. In a real project you usually want to keep reading sensors or buttons while a beep plays. This version uses millis() to check the time instead, so loop() never stops. It gives a 100 ms beep once a second, the classic "armed" signal of an alarm.
// Beep without delay(): the rest of loop() keeps running.
const int BUZZER_PIN = 8;
unsigned long lastToggle = 0;
bool buzzing = false;
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
unsigned long now = millis();
unsigned long interval = buzzing ? 100 : 900; // 100 ms beep every second
if (now - lastToggle >= interval) {
buzzing = !buzzing;
digitalWrite(BUZZER_PIN, buzzing ? HIGH : LOW);
lastToggle = now;
}
// read sensors, update a display, check buttons... nothing is blocked
}Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| No sound at all | Buzzer reversed, or it is a passive buzzer | Swap the leads; a passive buzzer only clicks on 5 V and needs tone() |
| Beeps nonstop from power-up | Active-LOW module | Set ACTIVE_LOW = true |
| Transistor circuit silent | Transistor pins in the wrong order, or no base resistor | Check E, B, C for your part; use 1 kΩ from D8 to the base |
| Faint sound | Sticker still on, or buzzer powered from 3.3V | Remove the sticker; use the 5V pin |
| Nothing in the Serial Monitor | Wrong baud rate or port | Set 9600 baud and pick the Uno's port |
| Uno resets on each beep | Supply dipping when the buzzer starts | Add a 100 µF capacitor across 5V and GND near the buzzer |
Projects to build next
- Door alarm: a reed switch on D2 and a magnet on the door. Sound the alarm pattern when the door opens.
- Reaction timer: a random beep, then measure how fast a button is pressed and print the time.
- Parking sensor: read an HC-SR04 and shorten the gap between beeps as the distance falls.
- Keypad entry feedback: a 30 ms chirp for every key, a long tone for a wrong code.
