Buzzer with Arduino Uno
Interfacing Piezo Buzzer with Arduino UNO for Sound Generation
Interfacing Piezo Buzzer with Arduino UNO for Sound Generation demonstrates how a piezoelectric buzzer can be connected to an Arduino UNO board to generate sound using digital output signals.
A piezoelectric buzzer is an electronic device commonly used for producing sound and alert signals.
The Arduino UNO controls the buzzer by providing HIGH and LOW signals through a digital GPIO pin.
In this experiment, the buzzer is connected to digital pin 4 of the Arduino UNO. The buzzer is turned ON for 1 second and turned OFF for 1 second. This process is repeated continuously.
Arduino UNO → Digital Pin 4 → Piezo Buzzer → Sound
Theory
A piezoelectric buzzer is an electronic device commonly used to produce sound.
The piezoelectric buzzer works on the inverse principle of piezoelectricity.
The buzzer contains a piezoelectric element and a diaphragm.
When an alternating electrical signal is applied to the piezoelectric element, it produces mechanical vibrations. These vibrations cause the diaphragm to move, generating sound waves.
A passive piezo buzzer requires an alternating electrical signal of a suitable frequency to produce a continuous audible tone.
The Arduino UNO can control the buzzer using digital output signals.
- HIGH (5V): Applies a HIGH voltage to the buzzer signal pin.
- LOW (0V): Applies a LOW voltage to the buzzer signal pin.
By repeatedly changing the output state between HIGH and LOW, the Arduino UNO controls the buzzer operation.
Electrical Signal → Piezoelectric Element → Diaphragm Vibration → Sound
Piezo Buzzer Pins
The piezo buzzer has two pins:
| Pin | Connection | Function |
|---|---|---|
| + | Arduino UNO Digital Pin 4 | Signal input |
| − | GND | Ground |
The pin marked with + is the signal pin and is connected to digital pin 4 of the Arduino UNO.
The pin marked with − is the ground pin and is connected to the GND pin of the Arduino UNO.
Sound Generation
Sound is generated when an electrical signal is applied to the piezoelectric element.
In this experiment, the Arduino UNO generates HIGH and LOW output signals using the digitalWrite() function.
The buzzer is activated for 1000 milliseconds and deactivated for another 1000 milliseconds.
This ON/OFF operation produces a repeated sound pattern.
Note: The reference program is suitable for an active buzzer that produces sound when a DC voltage is applied. A passive piezo buzzer generally requires a frequency-generating function such as tone() to produce a continuous audible tone.
Applications
Piezoelectric buzzers are commonly used in:
- Refrigerators
- Automotive instruments
- Security and alarm systems
- Electronic instruments
- Home appliances
- Notification systems
- Industrial warning systems
Connections
The buzzer is connected to digital pin 4 of the Arduino UNO.
| Device | Pin | Arduino UNO | Function |
|---|---|---|---|
| Piezo Buzzer | + | Digital Pin 4 | Signal input |
| Piezo Buzzer | − | GND | Ground |
Note: The buzzer signal pin is connected to digital pin 4, while the negative pin is connected to GND.
Algorithm
The following algorithm is used for controlling the buzzer using digital output:
- Start the Arduino IDE.
- Connect the Arduino UNO board to the computer using a USB cable.
- Declare a variable to assign digital pin 4 as the buzzer pin.
- In the void setup() function, configure the selected pin as OUTPUT.
- In the void loop() function, make the selected pin HIGH.
- Keep the buzzer ON for 1000 milliseconds.
- Make the selected pin LOW.
- Keep the buzzer OFF for 1000 milliseconds.
- Repeat the process continuously.
The overall operation is:
GPIO HIGH → Buzzer ON → Delay 1000 ms → GPIO LOW → Buzzer OFF → Delay 1000 ms → Repeat
Working
The Arduino UNO generates digital output signals on pin 4 connected to the buzzer.
The working sequence is:
- The Arduino UNO initializes digital pin 4 as OUTPUT.
- The digital pin is set to HIGH.
- The buzzer is activated and produces sound.
- The buzzer remains ON for 1000 milliseconds.
- The digital pin is set to LOW.
- The buzzer is deactivated.
- The buzzer remains OFF for 1000 milliseconds.
- The process repeats continuously.
Arduino UNO → Digital HIGH → Buzzer ON
Arduino UNO → Digital LOW → Buzzer OFF
Observation
Buzzer ON/OFF Control Program
The following program is used to control a buzzer connected to digital pin 4 of the Arduino UNO.
#define buz D4
void setup()
{
pinMode(buz, OUTPUT);
}
void loop()
{
digitalWrite(buz, HIGH);
delay(1000);
digitalWrite(buz, LOW);
delay(1000);
}
Program Explanation
- The buzzer pin is defined using the #define preprocessor directive.
- The variable buz is assigned to digital pin 4.
- The pinMode() function configures digital pin 4 as OUTPUT.
- The digitalWrite(buz, HIGH) function sets the buzzer pin HIGH and activates the buzzer.
- The delay(1000) function keeps the buzzer ON for 1000 milliseconds (1 second).
- The digitalWrite(buz, LOW) function sets the buzzer pin LOW and deactivates the buzzer.
- Another delay of 1000 milliseconds keeps the buzzer OFF for 1 second.
- The loop() function repeats this operation continuously.
Observation Table
| Step | Arduino Output | Buzzer State | Duration |
|---|---|---|---|
| 1 | HIGH | ON | 1000 ms |
| 2 | LOW | OFF | 1000 ms |
Result
The Arduino UNO successfully interfaces with the piezo buzzer using digital pin 4.
The buzzer turns ON for 1000 milliseconds and OFF for 1000 milliseconds continuously.
Thus, the buzzer is successfully controlled using digital HIGH and LOW output signals of the Arduino UNO.