Skip to content

Active Buzzer

Component Passive Buzzer
Type Output
Function Generate sound

Introduction

A passive buzzer is a type of electronic buzzer that generates sound when a voltage is applied to it. It is an output device that is commonly used in electronic projects to provide audible feedback to the user. Passive buzzers are often used in alarm systems, timers, and other applications where an audible signal is required.

You use a passive buzzer (instead of an active buzzer) when you want to use an alternating signal to generate sound. You can use a passive buzzer with a square wave signal to generate different tones and melodies.

Pin Description

A passive buzzer has two pins: a positive pin and a negative pin. You connect the positive pin to a digital output pin on a microcontroller, and the negative pin to the ground pin. When you apply an alternating signal to the positive pin, the buzzer generates sound.

Code Example

The following code example demonstrates how to generate a sound using a passive buzzer connected to an Arduino board.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#define BUZZER_PIN 8 // define the buzzer pin

void setup() {
  pinMode(BUZZER_PIN, OUTPUT); // set the buzzer pin as an output
}

void loop() {
  tone(BUZZER_PIN, 1000); // generate a 1000Hz tone
  delay(1000); // wait for 1 second
  noTone(BUZZER_PIN); // stop the tone
  delay(1000); // wait for 1 second
}

In this example, we use the tone function to generate a 1000Hz tone on the buzzer pin, causing the buzzer to generate sound. We then wait for 1 second using the delay function, and then use the noTone function to stop the sound.