One of the great things about Arduino is that it can be used to control a wide range of devices. In this tutorial, we will be using an active buzzer with Arduino. An active buzzer is a type of speaker that emits sound when it is powered on. They are commonly used in alarm systems and door bells. In this tutorial, we will show you how to use an active buzzer with Arduino to create your own alarm system or door bell!
Arduino and the Versatility of Its Uses
The Arduino is a highly useful tool for a variety of projects. You can connect it to a computer to program it, and it is compatible with a variety of other electronics. The Arduino is perfect for simple projects like turning on an LED, but it can also be used for more complex projects like controlling a motor.
In this tutorial, we’ll be discussing how to use an active buzzer with Arduino. This type of buzzer produces sound when an electric current is applied to it. It’s a simple and easy way to add audio output to your project.
One common use for an active buzzer is as an alarm. You can program the Arduino to turn on the buzzer when certain conditions are met, such as when motion is detected or a button is pressed. Active buzzers can also be used to create musical tones and rhythms. By programming the Arduino to control the frequency of the sound produced by the buzzer, you can create simple melodies and tunes. [1], [2]
What Are Piezoelectric buzzers?
Piezoelectric buzzers are self-generating sound devices. This type of buzzer does not require an external DC power supply to produce sound. Piezoelectricity is the ability of certain materials to generate an electric charge in response to applied mechanical stress.
Different types of piezoelectric buzzers
There are two main types of piezoelectric buzzers: active and passive.
Active Buzzers
Active buzzers have an internal oscillator that creates the sound. This means that they will continue to produce sound as long as voltage is applied to them. So you won’t need an external circuit to make them create tones. This is why most people use active buzzers because they are easier to use and more common. You can find them in all sorts of electronic devices like alarms, computers, beepers, and smoke detectors.
Passive buzzers
Passive buzzers do not have an internal oscillator feature. This means that they can only produce sound when an alternating current is applied to them, which makes them more versatile but also a little more difficult to use. The frequency of the sound produced by a passive buzzer depends on the frequency of the AC signal. Passive buzzers are typically used in musical applications.
So basically, an active buzzer can create sound independently while a passive buzzer needs an external signal source for that. [2]
Connecting an Active Buzzer to Arduino
Now that we know what active buzzers are, let’s go over how to connect one to your Arduino.
You’ll need:
- An active buzzer
- Arduino board
- Breadboard
- Jumper wires
First, you’ll want to insert the active buzzer into the breadboard. Buzzer’s module has three pins: GND, I/O, and VCC. The GND pin is connected to ground, the I/O pin is the signal pin, and the VCC is the power supply. Left pin of your buzzer is negative while the right pin is positive.
In some cases, you may want to connect a buzzer to Arduino using a transistor. This is because the Arduino may overload trying to provide enough current to power the buzzer on its own. The transistor will act as a switch that turns the buzzer on and off.
The benefits of a breadboard, as opposed to a solderless breadboard, is that it’s reusable. You can remove and insert components as you please without having to worry about damaging the board or the components.
Now that we know how to set up our hardware, let’s move on to programming our active buzzer with Arduino! [2], [3], [4], [5]
Controlling the buzzer via code
The code for this project is pretty simple. Connect the Arduino to your computer and open up the Arduino IDE. If you’ve never used the Arduino IDE before, don’t worry! It’s pretty straightforward. But you may have to install drivers first before you can upload code to your Arduino board.
Once the Arduino IDE is open, copy and paste the following code into the editor:
void setup() {
// put your setup code here, to run once:
pinMode(9, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
void loop() {
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}
}
Explanation of the code
In the void loop() section of our code, we use the digitalWrite
function to turn the buzzer on and off. Now, we’ll add a few lines of code inside of the void loop(). This is where we’ll write all of the code that we want to execute over and over again.
When we set the value of digitalWrite
to HIGH, it turns on the power and allows current to flow through. This makes the piezo element vibrate and create sound. When we set it LOW, it turns off the power and stops making noise.
We also use delay to control how long the buzzer is on and off. The number inside of the delay function is in milliseconds, which in our case means that it will wait for one second before turning off. You can change it as you wish.
With this simple code you can turn the active buzzer ON and OFF. There are many ways you can improve this project with, like adding a button so that you can turn the buzzer on and off manually. It’s all up to you and your imagination at the end of the day so test a variety of applications! [2], [4]
Read more guides to improve your Arduino knowledge:
- Interfacing a Flame Sensor with Arduino Guide
- How to Use a Microphone with Arduino?
- How to Stop an Arduino Program?
FAQ
How do I connect my buzzer to my Arduino?
To use an active buzzer with Arduino, you’ll need to connect the positive lead of the buzzer to a digital output pin on the Arduino board. Then connect the negative lead of the buzzer to one of the ground pins on the Arduino board. Once you have done this, you can use code to control when the buzzer sounds. You can find more detailed instructions above.
How does an active buzzer work?
An active buzzer has an internal electronic circuit. This means it will start to beep as soon as it receives power. It doesn’t need any extra signal or code from Arduino in order for it to work.
How do you activate the passive buzzer?
Activating a passive buzzer is harder because it requires an external power source that can provide enough current to make the piezo element vibrate. You will also need a transistor to act as a switch since the Arduino cannot supply enough current on its own to power the buzzer.
With an active buzzer, however, you only need to connect it to one of the Arduino’s digital output pins and ground. Active buzzers have an internal oscillator that produces a tone when powered. This makes them much easier to use with microcontrollers like the Arduino.
Does the Arduino Uno have a built-in buzzer?
No, the Arduino Uno does not have a built-in buzzer. You will need to purchase an active buzzer and connect it to one of the Arduino’s digital output pins as we have shown in our tutorial.
Useful Video: How to use Active Buzzer with Arduino& Raspberry Pi
Final Words
Arduino is a great board for all sorts of projects, one of which is experimenting with buzzers. Active buzzers come with an internal oscillator feature that you can use to create tones and sounds without requiring an external power source.
In this post, we showed you how to use an active buzzer with Arduino. This is a really simple project, but it’s a lot of fun and can be used in all sorts of different applications. We hope you found this tutorial helpful. Go ahead and create many other interesting projects with Arduino and a buzzer!
References:
- https://www.arduino.cc/
- https://www.circuitbasics.com/how-to-use-active-and-passive-buzzers-on-the-arduino/
- https://electropeak.com/learn/interfacing-active-buzzer-with-arduino/
- https://startingelectronics.org/tutorials/arduino/modules/active-buzzer/
- https://bgsu.instructure.com/courses/1157282/pages/tutorial-active-buzzer
- https://eu.mouser.com/new/tdk/tdk-ps-piezoelectric-buzzer/
Leave a Review