Quick answer: An active buzzer has a built-in tone circuit (an oscillator), so steady 5 V makes it beep one fixed note. A passive buzzer has none. It only clicks on steady 5 V and needs a square wave from tone() to play any note you choose.
- Not sure which one you have? Power the module (VCC to 5 V, GND to GND), then touch the I/O pin to GND with a jumper. A steady beep means active. One click means passive.
- For a simple beep or alarm, use the active buzzer with
digitalWrite(). - For a melody, use the passive buzzer with
tone(pin, frequency). - On our modules LOW means sound and HIGH means silent. If the buzzer beeps non-stop, call
digitalWrite(pin, HIGH)beforepinMode(pin, OUTPUT).
Active vs passive buzzer: the difference
A buzzer is a small sounder that turns an electrical signal into a beep. The Active Buzzer Module has its own oscillator sealed under the black can. Give it DC and it drives itself at about 2.3 kHz. You get one note, and your pin only switches it on or off.
The Passive Buzzer Module has no oscillator, only the coil and diaphragm. Its pitch is the frequency of the square wave you send. Steady DC gives a single click, then silence.
| Feature | Active buzzer | Passive buzzer |
|---|---|---|
| Built-in oscillator | Yes | No |
| On steady 5 V | Beeps one fixed note (about 2.3 kHz) | One click, then silence |
| Arduino code | digitalWrite() |
tone(pin, frequency) |
| Pitch | Fixed by the buzzer | Set by your code |
| Best for | Beeps, alerts and alarms | Melodies and changing tones |
| Underside of a bare one | Sealed flat with black potting compound | Drive coil and two solder points in plain sight |
| Our part | Active Buzzer Module | Passive Buzzer Module |
Is a piezo buzzer active or passive? Either. Piezo or magnetic names the sounding element, and both are made with or without a built-in driver. The SFM-20B below is piezo and active.
Parts list: tell the two buzzers apart, then build the alarm
Louder option
| Item | Price | Qty | |
|---|---|---|---|
SFM-20B Active Buzzer DC 3-24V Piezoelectric Long Continous BeepSFM208S | RM3.15 |
A 3–24 V active buzzer on flying leads for when a module is not loud enough. It draws at most 12 mA at its rated 12 V, so an Uno pin drives it directly at 5 V. Its tinned stranded ends fit no header, so twist them onto jumper tips or land them in a screw terminal.
The bare passive buzzer is the same element on two stiff pins for a breadboard. The KY-006 passive module is rated 1.5–2.5 kHz.
How to tell which buzzer you have
Our Active Buzzer Module and Passive Buzzer Module look identical: the same blue PCB marked MH-FMD, with pins labelled GND, I/O and VCC.
Jumper test, no code. On a powered Uno, connect VCC to 5 V and GND to GND, then plug the I/O jumper into another GND socket for a second. A steady beep means active. One faint click means passive. This is safe: 0 V on I/O is the normal sound state, and the on-board 1 kΩ resistor limits the I/O current to about 4 mA. Remove the jumper afterwards, because a silent passive buzzer still has current in its coil.
Code test. With I/O on D8, this sketch starts silent, then holds the pin LOW for the same result. Unplug the module straight after the test.
const uint8_t IO_PIN = 8;
void setup() {
digitalWrite(IO_PIN, HIGH); // silent first - see the wiring section
pinMode(IO_PIN, OUTPUT);
delay(1000);
digitalWrite(IO_PIN, LOW); // steady DC from here on
}
void loop() {}
A bare buzzer works the other way round: (+) leg to the pin, the other leg to GND, and the pin HIGH to sound it. Put a 100 Ω resistor in the path and keep the test brief. A passive element is only a coil of a few tens of ohms, far less than a pin should drive on its own.
Underside, no power. Turn a bare buzzer over. An active one is sealed flat with black potting compound. A passive one shows its drive coil and two solder points.
Worth hearing them side by side:

Buzzer + and -: which leg is positive
A bare buzzer’s positive leg is marked on the part.
| Buzzer | How to find the positive leg |
|---|---|
| Buzzer module (active or passive) | No leg polarity to work out. The header pins are labelled GND, I/O and VCC. |
| Bare buzzer on two legs, such as our bare passive buzzer | A + is moulded into the top face near the rim. The leg on that side is positive, the other leg is negative. |
| SFM-20B on flying leads | Red lead is +, black lead is -. |
An active buzzer has a driver circuit inside, so it only works one way round (the AX-1205 datasheet drawing marks the positive pin with a +). If yours stays silent, check the mark first and do not leave it powered backwards. Follow the + on a passive buzzer too.
Wiring the buzzer modules to an Arduino Uno
The buzzer modules and the SW-18010P vibration module all have male pins, and the Uno’s headers are sockets, so one pack of male-to-female jumpers wires the whole build with no breadboard and no soldering (see which jumper wire fits what).
Check the silkscreen first. Both buzzer modules run GND, I/O, VCC, so a connector fitted back to front puts 5 V on the module’s ground pin. The vibration sensor runs AO DO GND VCC, so its GND is the third pin.
| Module pin | Uno pin | Why |
|---|---|---|
| Buzzer VCC (both modules) | 5V | Supplies the buzzer element through the module’s transistor |
| Buzzer GND (both modules) | GND | Return path for the buzzer current and the signal |
| Active buzzer I/O | D8 | Any ordinary digital pin; it only ever goes high or low |
| Passive buzzer I/O | D9 | Any digital pin. tone() works on all of them |
| Sensor VCC | 5V | Powers the LM393 comparator and both indicator LEDs |
| Sensor GND | GND | Third pin, not the last one. The silkscreen order is AO DO GND VCC |
| Sensor DO | D2 | D2 is interrupt INT0. An Uno has external interrupts on D2 and D3 only |
| Sensor AO | not used | Raw switch voltage; the digital output is what we want |
The Uno has only one 5 V socket, and the alarm needs two. Take the second feed from the 2×3 ICSP block: its 5 V pin sits beside the marked pin 1 in the other row, and a female jumper end pushes straight onto it. A mini breadboard also works.
Why does the buzzer beep non-stop when the sketch starts?
Both MakerHub buzzer modules are silkscreened 低电平触发 (low-level trigger), so LOW is the sound state and HIGH is silence.
On an Uno, pinMode(pin, OUTPUT) switches on the pin driver while the output latch still holds zero, so the pin goes LOW and the buzzer sounds at once. The fix is two lines, in this order:
digitalWrite(BUZZER_PIN, HIGH); // set the latch while still an input
pinMode(BUZZER_PIN, OUTPUT); // pin comes up HIGH, never passes through LOW
noTone() has the same problem. The AVR core ends it with digitalWrite(_pin, 0), and a tone() with a duration calls noTone() when the time runs out. Follow every noTone() with digitalWrite(pin, HIGH).
Why LOW means sound. An S8550 PNP transistor switches the buzzer, with the resistor marked 102 (1 kΩ) between its base and the I/O pin. At 0 V on I/O about 4 mA flows out of the base and the buzzer gets 5 V. At 5 V no base current flows. The pin sinks that 4 mA, well inside the 20 mA per I/O pin the Uno is specified for.
An ESP32’s 3.3 V HIGH cannot switch the transistor off while the module runs on 5 V, so the buzzer never stops. Power the module from the 3.3 V rail instead.

Play a melody with tone() on the passive buzzer
The Passive Buzzer Module plays notes through tone(), which hands the pin to a hardware timer and returns at once, so the note keeps playing while your code carries on. The module’s transistor inverts the wave, which does not change its frequency or pitch.
On an Uno tone() uses Timer2, so PWM on pins 3 and 11 stops while a note plays, and only one note sounds at a time.
// Eight-note scale on the PASSIVE buzzer module. Uno, I/O on D9.
const uint8_t IO_PIN = 9;
const uint8_t BUZZER_OFF = HIGH; // low-level trigger: HIGH is silent
const int NOTES[] = { 262, 294, 330, 349, 392, 440, 494, 523 }; // C4..C5
const uint8_t NOTE_COUNT = sizeof(NOTES) / sizeof(NOTES[0]);
const int NOTE_MS = 250;
const int GAP_MS = 60;
// noTone() ends by writing the pin LOW, and on a low-level-trigger
// module LOW means "sound". Always park the pin HIGH afterwards.
void silence() {
noTone(IO_PIN);
digitalWrite(IO_PIN, BUZZER_OFF);
}
void setup() {
digitalWrite(IO_PIN, BUZZER_OFF); // silent before the pin becomes an output
pinMode(IO_PIN, OUTPUT);
}
void loop() {
for (uint8_t i = 0; i < NOTE_COUNT; i++) {
tone(IO_PIN, NOTES[i]); // square wave at this frequency, hands off
delay(NOTE_MS); // the note keeps sounding while we wait
silence();
delay(GAP_MS);
}
delay(2000);
}
Drop silence() and the scale runs together into one unbroken howl. A video lesson on passive buzzers:
Build a vibration alarm with the active buzzer
The Active Buzzer Module becomes a knock alarm when you add the SW-18010P vibration sensor, a coil spring around a centre pin, normally open. One knock makes the spring touch the pin several times in quick succession. The module’s LM393 turns that into clean edges: DO rests high and pulses low.
Set the blue trimmer first. Wound to either end, DO sits stuck and the alarm never fires. Power the board, leave it still and turn the trimmer until the DO-LED has just gone out, then tap the bench and watch it flash. If the alarm never reacts, check this before you suspect the buzzer.
The sketch does four things:
- Waits 10 seconds after power-up, so setting it down does not count.
- Ignores repeat edges within 40 ms (one knock rattling).
- Needs 4 knocks inside 1.5 seconds, so a passing lorry is not enough.
- Runs the siren for 5 seconds on
millis(), which leaves the loop free for a silence button.
// Vibration alarm. SW-18010P DO -> D2, ACTIVE buzzer I/O -> D8. Uno.
const uint8_t SHAKE_PIN = 2; // D2 is INT0 - the only reason this pin is used
const uint8_t BUZZER_PIN = 8;
const uint8_t BUZZER_ON = LOW; // low-level trigger module
const uint8_t BUZZER_OFF = HIGH;
const unsigned long ARM_DELAY_MS = 10000UL; // time to set it down and walk off
const unsigned long BOUNCE_MS = 40UL; // one knock rattles the spring
const unsigned long WINDOW_MS = 1500UL; // knocks must land inside this
const uint8_t PULSES_NEEDED = 4; // lower = jumpier alarm
const unsigned long SIREN_MS = 5000UL;
volatile unsigned long lastEdgeMs = 0;
volatile unsigned int pulses = 0;
bool armed = false, sounding = false, windowOpen = false;
unsigned long windowStart = 0, sirenStart = 0;
// Runs the instant DO falls, whatever loop() is doing. Counting only -
// the decisions live in loop() where they are easy to read.
void onShake() {
unsigned long now = millis();
if (now - lastEdgeMs < BOUNCE_MS) return; // still the same knock rattling
lastEdgeMs = now;
pulses++;
}
// pulses is 16-bit, so the AVR reads it in two instructions. Block
// interrupts across the read or an edge can land between the halves.
unsigned int readPulses() {
noInterrupts();
unsigned int n = pulses;
interrupts();
return n;
}
void clearPulses() {
noInterrupts();
pulses = 0;
interrupts();
}
void setup() {
digitalWrite(BUZZER_PIN, BUZZER_OFF); // BEFORE pinMode - never pass through LOW
pinMode(BUZZER_PIN, OUTPUT);
// The LM393's output is open-collector: it can pull the line down but
// never push it up, so give it a pull-up to fall away from.
pinMode(SHAKE_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(SHAKE_PIN), onShake, FALLING);
}
void loop() {
unsigned long now = millis();
// 1. Arming delay - ignore your own handling while you leave the room.
if (!armed) {
if (now >= ARM_DELAY_MS) { clearPulses(); armed = true; }
return;
}
// 2. Siren already running: let it finish, then re-arm quietly.
if (sounding) {
if (now - sirenStart >= SIREN_MS) {
digitalWrite(BUZZER_PIN, BUZZER_OFF);
sounding = false;
windowOpen = false;
clearPulses(); // knocks during the siren do not retrigger it
}
return;
}
unsigned int n = readPulses();
if (n == 0) return;
// 3. The first knock opens a window.
if (!windowOpen) { windowOpen = true; windowStart = now; }
// 4. Enough knocks inside that window - this is real.
if (n >= PULSES_NEEDED) {
digitalWrite(BUZZER_PIN, BUZZER_ON);
sounding = true;
sirenStart = now;
return;
}
// 5. Window expired without enough knocks - a passing lorry. Forget it.
if (now - windowStart >= WINDOW_MS) {
windowOpen = false;
clearPulses();
}
}
Mount the sensor on the thing you are protecting. If one sharp tap fires the alarm, raise BOUNCE_MS. If a real shove never reaches four counts, lower PULSES_NEEDED or widen WINDOW_MS.

Keep it all on the Uno’s 5 V rail, away from 230 V mains. Test the louder SFM-20B at arm’s length, not beside your ear. It has no transistor in front of it, so it sounds on HIGH: red lead to D8, black to GND, and swap the constants so BUZZER_ON is HIGH and BUZZER_OFF is LOW.
For other triggers, see our PIR motion light, MQ-2 smoke alarm and flame alarm builds. An IR remote also makes a tidy silence button.
FAQ
Can I use tone() with an active buzzer?
You can call it, but the pitch will not change. The oscillator inside is fixed, so any frequency you pass only switches it on and off. Use a passive buzzer for anything with a tune.
Why does my buzzer beep non-stop when the Arduino powers up?
Usually nothing is broken. Both our modules are low-level trigger, so a pin at 0 V means sound. Call digitalWrite(pin, HIGH) first, then pinMode(pin, OUTPUT).
Which buzzer should I choose for a school alarm project?
For an RBT or school alarm project, choose the active module unless the marking scheme asks for a tune. It needs one line of code and has no timer to explain.
Does a buzzer need a resistor?
Our buzzer modules do not. The transistor and 1 kΩ resistor are on the board, so the pin only handles about 4 mA. A small bare buzzer wired straight to a pin does: use 100 Ω for a quick test and a transistor for a permanent build.
How do I make the alarm louder?
Fit the SFM-20B. It runs from 3 to 24 V and draws at most 12 mA at its rated 12 V, so an Uno pin drives it directly at 5 V. It sounds on HIGH, so swap BUZZER_ON and BUZZER_OFF when you fit it.
Last updated November 2026. Stuck? Chat with us on WhatsApp.



Arduino Uno Compatible SMD UNO R3 with Type B Cable - ATMEGA328P with CH340G-Microcontroller Project
Buzzer Active Passive Buzzer 5V Electronic Sound Alarm Module Tone Piezo - Active Buzzer Module
Buzzer Active Passive Buzzer 5V Electronic Sound Alarm Module Tone Piezo - Passive Buzzer Module
Tilt Sensor Vibration Sensor Tilt Switch Module Alarm Trigger SW1801P For Arduino Application - VIBRATION/ TILT SENSOR
40pcs Dupont Wire 10cm 20cm 30cm for Breadboard DIY Experiment Jumper Wire Breadboard wire - DUPONT WIRE M-F 20CM
SFM-20B Active Buzzer DC 3-24V Piezoelectric Long Continous Beep
Pingback: 3 Primary School Science Projects: No Code, No Solder