Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

Active buzzer module with Arduino Uno — wiring and beep patterns

Wire an active buzzer module to an Arduino Uno R3 on D8, handle high- and low-level trigger boards, and make beep, warning and alarm patterns.

Arduino C++Verified — core avr 1.8.8, 3 Nov 2026Compile-only

Community draft — report a mistake

An active buzzer makes one loud, fixed tone the moment it gets power. That makes it the simplest way to add an alarm — for a gas leak, a water tank that is full, or a door left open. The module version adds a transistor, so the Uno pin only switches it.

On the Uno, I/O goes to D8 and the module runs from 5V. Before you write code, check which kind of module you have: most beep when I/O is HIGH, but “low-level trigger” boards beep when it is LOW. The sketch handles both with one setting.

It plays three patterns you can reuse: a short confirmation beep, a triple warning and a long alarm.

Wiring

Arduino Uno R3Only the pins used are shown · 5 V logicActive buzzer module (high-level trigger)5VGNDD8I/OVCCGND
Every connection
Arduino Uno R3Active buzzer module (high-level trigger)WireNotes
D8I/OyellowDrives the module’s transistor only — a few mA from the pin.
5VVCCredAbout 25–30 mA while beeping. 5 V is louder than 3.3 V.
GNDGNDblack

3.3–5 V part, 5 V board. The I/O pin only drives the module's transistor, so a 3.3 V GPIO is enough even when the buzzer runs from 5 V. Check the label: "high-level trigger" beeps when I/O is HIGH; "low-level trigger" modules (with a PNP transistor) beep when I/O is LOW.

Board quirks

  • An active buzzer beeps at its own fixed pitch when powered — use digitalWrite(), not tone(). To tell it from a passive one: connect it to 5 V directly. If it beeps, it is active (and usually has a sealed back and a sticker).
  • Modules marked low-level trigger (PNP transistor) beep when I/O is LOW. Set ACTIVE_LOW = true and the sketch keeps them quiet at start-up.
  • The Uno pin is set to its quiet level before it becomes an output, so the buzzer doesn’t chirp at every reset.
  • These patterns use delay(), which freezes the rest of the sketch. In an alarm that also reads sensors, switch the buzzer on and off with millis() timing instead.

Code

active-buzzer-uno.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// Active buzzer module on an Arduino Uno R3.
// I/O → D8, VCC → 5V, GND → GND. An active buzzer has its own oscillator:
// HIGH = beep (on high-level-trigger modules), LOW = quiet.
const uint8_t BUZZER_PIN = 8;
const bool ACTIVE_LOW = false;  // true for "low-level trigger" modules

void buzz(bool on) {
  digitalWrite(BUZZER_PIN, (on ^ ACTIVE_LOW) ? HIGH : LOW);
}

void beep(unsigned int onMs, unsigned int offMs, uint8_t times) {
  for (uint8_t i = 0; i < times; i++) {
    buzz(true);
    delay(onMs);
    buzz(false);
    delay(offMs);
  }
}

void setup() {
  digitalWrite(BUZZER_PIN, ACTIVE_LOW ? HIGH : LOW);  // quiet from the first instant
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.begin(9600);
  Serial.println(F("Active buzzer on D8"));
}

void loop() {
  Serial.println(F("Single beep (button OK)"));
  beep(80, 0, 1);
  delay(1500);
  Serial.println(F("Three short beeps (warning)"));
  beep(100, 100, 3);
  delay(1500);
  Serial.println(F("Long alarm pattern"));
  beep(400, 200, 4);
  delay(3000);
}

Expected serial output

Serial Monitor · 9600Output
Active buzzer on D8
Single beep (button OK)
Three short beeps (warning)
Long alarm pattern

Common errors

Buzzer beeps all the time, even before upload

A low-level trigger module with the pin LOW (or floating). Set ACTIVE_LOW = true.

Only a faint click instead of a beep

It is a passive buzzer. Use tone() — see the passive buzzer guide.

Beep is weak

VCC on 3.3V instead of 5V, or a bare buzzer without a transistor drawing too much from the pin. Use the module, powered from 5V.

↑↓ to move · Enter to open