Bird
0
0
Arduinoprogramming~30 mins

Passive vs active buzzer difference in Arduino - Hands-On Comparison

Choose your learning style9 modes available
Passive vs Active Buzzer Difference
📖 Scenario: You are building a simple Arduino project to understand the difference between a passive and an active buzzer. Buzzers are used in many devices to make sounds, like alarms or notifications.
🎯 Goal: You will write code to control both a passive buzzer and an active buzzer connected to an Arduino. You will see how the active buzzer sounds with just turning it on, while the passive buzzer needs a tone signal to make sound.
📋 What You'll Learn
Create two integer variables for buzzer pins: activeBuzzerPin and passiveBuzzerPin
Create an integer variable toneFrequency for the passive buzzer frequency
Write code to turn on the active buzzer by setting its pin HIGH
Write code to play a tone on the passive buzzer using tone() function
Write code to stop the tone on the passive buzzer using noTone()
Print messages to the Serial Monitor to show which buzzer is sounding
💡 Why This Matters
🌍 Real World
Buzzers are used in alarms, timers, and notifications in many electronic devices. Understanding how to control them helps in building interactive projects.
💼 Career
Knowledge of hardware components like buzzers and how to program them is useful for embedded systems developers, IoT engineers, and electronics hobbyists.
Progress0 / 4 steps
1
Set up buzzer pins
Create two integer variables called activeBuzzerPin and passiveBuzzerPin and set them to 8 and 9 respectively.
Arduino
Hint

Use int to create variables for the buzzer pins.

2
Set tone frequency for passive buzzer
Create an integer variable called toneFrequency and set it to 1000 (for 1000 Hz sound).
Arduino
Hint

Choose a frequency value in Hertz for the passive buzzer tone.

3
Turn on active buzzer and play tone on passive buzzer
In the setup() function, set both buzzer pins as OUTPUT. Then turn on the active buzzer by writing HIGH to activeBuzzerPin. Use tone(passiveBuzzerPin, toneFrequency) to play the tone on the passive buzzer.
Arduino
Hint

Use pinMode to set pins as output. Use digitalWrite to turn on active buzzer. Use tone() for passive buzzer.

4
Stop passive buzzer tone and print messages
In the loop() function, stop the passive buzzer tone using noTone(passiveBuzzerPin). Then print "Active buzzer is ON" and "Passive buzzer tone stopped" to the Serial Monitor. Add a delay of 2000 milliseconds.
Arduino
Hint

Use noTone() to stop the passive buzzer. Use Serial.println() to print messages. Use delay() to pause.