Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
30 min
Share

Make an alarm sound using the passive buzzer

A “buzzer” is an electrical device that makes an alarm sound. It is usually used to indicate when someone has pressed a button or to give a warning sound. Buzzers come in different shapes and sizes.

Project Video

Overview

In this tutorial, we will learn how to use a buzzer to make an alarm tone that works every minute as a clock alarm.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Passive Buzzer – 5V
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the passive buzzer and the Arduino, as shown in the image below.

 Connections from the Arduino to the passive buzzer:


     • Arduino GND pin → buzzer GND pin (- pin)


     • Arduino pin 11 → buzzer VCC pin (+ pin)


Coding


*/

// Define the variable buzzer to Digital Output 11
const int buzzer = 11;


// Commands inside void setup run once
void setup()
{

 // buzzer is defined as an output
 pinMode(buzzer, OUTPUT);

 // Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);

}

// Commands inside void loop run forever
void loop()
{


 // Generates a square wave of the specified frequency (1000) on a pin (buzzer)for a duration of 500 Millisecond to make a tone
 tone(buzzer, 1000, 500);

 //delay for one minute
 delay(60000);

 // print "Sensor Read= " to the serial monitor at the same line
 Serial.println("One minute has passed, Alarm!");

 // stop generating the tone
 noTone(buzzer);

}

Testing it Out

You should also make sure you have chosen the right baud rate (9600) as specified in the code.
know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as seen in the image below, the serial monitor displays the status of the buzzer whenever it is turned on. The state is displayed every one minute due to the delay we added in our code. You will also hear the tone that the buzzer makes every minute and lasts for half a second.

know when your plant needs watering

Resources

No items found.