Codey OnlineArduino & ESP32 component library › Passive Buzzer Module
Passive Buzzer Module
Output

Passive Buzzer Module

A passive buzzer module generates sound by converting a digital square-wave (often via PWM) applied to the S control pin into audible tones. Connect VCC to your supply and GND to ground, then vary the PWM/toggling on S to change the perceived pitch or patterns.

Width: 27.7 mm

Pinout — Passive Buzzer Module

Pin Signal Description
S PWM Buzzer drive input — apply a PWM/square wave tone signal from the controller
VCC power Positive supply for the buzzer module, typically connected to 5V
GND ground Ground reference for the buzzer module and control signal

Example wiring diagram — Passive Buzzer Module

From To Wire
board:D9 x1:S green
board:5V x1:VCC red
board:GND x1:GND black

Example Arduino code — Passive Buzzer Module

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// Passive Buzzer Module example for Arduino Uno
// Plays a short melody using a PWM/square wave output on D9.

const int BUZZER_PIN = 9;

// Note frequencies in Hz
const int NOTE_C4 = 262;
const int NOTE_D4 = 294;
const int NOTE_E4 = 330;
const int NOTE_G4 = 392;
const int NOTE_C5 = 523;

void playTone(int frequency, int duration) {
  tone(BUZZER_PIN, frequency);
  delay(duration);
  noTone(BUZZER_PIN);
  delay(50);
}

void setup() {
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.begin(9600);
  Serial.println("Passive Buzzer Module demo starting...");
}

void loop() {
  Serial.println("Playing melody...");

  playTone(NOTE_C4, 300);
  playTone(NOTE_D4, 300);
  playTone(NOTE_E4, 300);
  playTone(NOTE_G4, 300);
  playTone(NOTE_C5, 600);

  delay(1000);
}

Related components

3W amplifier MAX98357A I2S DAC

3W amplifier MAX98357A I2S DAC

Active Buzzer Module

Active Buzzer Module

⚙️

LED

LED Matrix Module MAX7219

LED Matrix Module MAX7219

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free