Bird
0
0
Arduinoprogramming~5 mins

Passive vs active buzzer difference in Arduino

Choose your learning style9 modes available
Introduction

Buzzers make sounds in electronic projects. Knowing the difference helps you pick the right one for your project.

You want a simple beep sound without extra parts.
You want to play different tones or melodies.
You need a buzzer that works with just power.
You want to control sound frequency precisely.
You want to save time by using a buzzer that beeps automatically.
Syntax
Arduino
// Active buzzer example
pinMode(buzzerPin, OUTPUT);
digitalWrite(buzzerPin, HIGH); // buzzer ON

delay(1000);
digitalWrite(buzzerPin, LOW); // buzzer OFF

// Passive buzzer example
pinMode(buzzerPin, OUTPUT);
tone(buzzerPin, 1000); // play 1000 Hz tone

delay(1000);
noTone(buzzerPin); // stop tone

Active buzzers beep when powered on with HIGH signal.

Passive buzzers need a tone signal to create sound.

Examples
This turns the active buzzer on for half a second, then off.
Arduino
// Active buzzer simple beep
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
This plays a 440 Hz tone on the passive buzzer for 1 second.
Arduino
// Passive buzzer play tone
pinMode(9, OUTPUT);
tone(9, 440); // play A note

delay(1000);
noTone(9);
Sample Program

This program alternates between beeping the active buzzer and playing a tone on the passive buzzer every half second.

Arduino
#define activeBuzzerPin 8
#define passiveBuzzerPin 9

void setup() {
  pinMode(activeBuzzerPin, OUTPUT);
  pinMode(passiveBuzzerPin, OUTPUT);
}

void loop() {
  // Active buzzer beep
  digitalWrite(activeBuzzerPin, HIGH);
  delay(500);
  digitalWrite(activeBuzzerPin, LOW);
  delay(500);

  // Passive buzzer play tone
  tone(passiveBuzzerPin, 1000); // 1000 Hz tone
  delay(500);
  noTone(passiveBuzzerPin);
  delay(500);
}
OutputSuccess
Important Notes

Active buzzers are easier to use but only beep at one fixed tone.

Passive buzzers let you create different sounds but need extra code.

Make sure to connect buzzers to the correct pins and use resistors if needed.

Summary

Active buzzers beep automatically when powered.

Passive buzzers need a signal to create sound.

Choose based on whether you want simple beeps or custom tones.