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.

Passive buzzer with Arduino Uno — tone(), notes and a siren

Play notes on a passive buzzer from an Arduino Uno R3 on D8 with tone(): the sargam scale and a siren, and see which PWM pins tone() takes over.

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

Community draft — report a mistake

A passive buzzer is a tiny speaker: it makes whatever pitch you drive it at. With the Uno’s built-in tone() function it can play notes, melodies and sirens. That makes it the better choice over an active buzzer when you want an alarm people actually notice.

Wire I/O to D8 and power the module from 5V. The thing to plan for on the Uno is that tone() takes over Timer2. While it plays, PWM on D3 and D11 stops, and it can’t share a sketch with IRremote.

The sketch plays the Indian sargam (Sa Re Ga Ma Pa Dha Ni Sa) up and down, then a rising and falling siren — a good starting point for a doorbell or a gas alarm.

Wiring

Arduino Uno R3Only the pins used are shown · 5 V logicPassive buzzer module5VGNDD8I/OVCCGND
Every connection
Arduino Uno R3Passive buzzer moduleWireNotes
D8I/Oyellow<code>tone()</code> works on any digital pin.
5VVCCred
GNDGNDblack

3.3–5 V part, 5 V board. On the 3-pin module the I/O pin only drives a transistor, so a 3.3 V GPIO is enough even with the buzzer on 5 V. The 2-pin bare buzzer or KY-006 can run straight from a GPIO through a 100 Ω resistor at low volume.

Board quirks

  • A passive buzzer has no oscillator: the Uno must send it a square wave at the note’s frequency, which is what tone() does. On plain 5 V it only clicks once.
  • tone() uses the Uno’s Timer2. While a note plays, analogWrite() on D3 and D11 doesn’t work, and IRremote (also Timer2) can’t be used in the same sketch.
  • Only one tone at a time on the Uno — a second tone() on another pin is ignored until noTone().
  • Passive buzzers are loudest near their resonance, about 2–4 kHz. Low notes like Sa (262 Hz) sound quiet; that is the buzzer, not the code.
  • Some KY-006 boards print the pins as S and − with an unlabelled middle pin. S is I/O, − is GND, the middle one is VCC.

Code

passive-buzzer-uno.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// Passive buzzer module on an Arduino Uno R3, played with tone().
// I/O → D8, VCC → 5V, GND → GND.
// tone() uses Timer2: while it plays, PWM on D3 and D11 stops working.
const uint8_t BUZZER_PIN = 8;

// Sargam in C: Sa Re Ga Ma Pa Dha Ni Sa' (Hz)
const uint16_t SARGAM[] = {262, 294, 330, 349, 392, 440, 494, 523};
const char* const NAMES[] = {"Sa", "Re", "Ga", "Ma", "Pa", "Dha", "Ni", "Sa'"};

void setup() {
  Serial.begin(9600);
  Serial.println(F("Passive buzzer on D8 - playing the sargam"));
}

void loop() {
  for (uint8_t i = 0; i < 8; i++) {
    Serial.print(NAMES[i]);
    Serial.print(' ');
    tone(BUZZER_PIN, SARGAM[i], 300);
    delay(350);  // tone() returns at once; wait for the note plus a short gap
  }
  Serial.println();
  delay(600);
  for (int8_t i = 7; i >= 0; i--) {
    tone(BUZZER_PIN, SARGAM[i], 200);
    delay(230);
  }
  Serial.println(F("Siren"));
  for (uint8_t r = 0; r < 3; r++) {
    for (uint16_t f = 600; f < 1400; f += 20) {
      tone(BUZZER_PIN, f);
      delay(5);
    }
    for (uint16_t f = 1400; f > 600; f -= 20) {
      tone(BUZZER_PIN, f);
      delay(5);
    }
  }
  noTone(BUZZER_PIN);
  delay(2000);
}

Expected serial output

Serial Monitor · 9600Output
Passive buzzer on D8 - playing the sargam
Sa Re Ga Ma Pa Dha Ni Sa'
Siren

Common errors

Only a click, no tone

You are using digitalWrite(), or it is an active buzzer driven with tone(). Use tone(pin, frequency) for passive buzzers.

LED on D3 or D11 stopped dimming

Timer2 is busy with tone(). Move the LED to D5, D6, D9 or D10.

“multiple definition of __vector_7” when compiling

Another library also uses Timer2 (IRremote, some servo or timer libraries). Use only one of them, or a different library for the buzzer.

↑↓ to move · Enter to open