Introduction
In this tutorial, we will learn about the KY-012 module, what is an Active Piezoelectric buzzer and we will build a simple project using the KY-012 module and an Arduino.
Active Buzzer Module KY-012
The KY-012 Module will be our main component for this tutorial. This module has an active piezoelectric buzzer mounted on a breakout board. Figure 1 shows the module as seen in fritzing. The seal is only part of the packaging, remove it prior to using the module.
Pinout
The KY-012 module has three pins.
Component Pin | Arduino Uno board Pin |
---|---|
(-) | GND |
middle | No connection |
S | Signal |
What is an Active Piezoelectric Buzzer?
An active piezoelectric buzzer is an electronic component that is composed of a piezoelectric transducer and an oscillator circuit to produce a tone. It only needs an external power supplied to make a sound.
Project - Arduino Buzzer
After learning about the KY-012 module and the Active Piezoelectric buzzer, it is now time to build a project using the module. Our project a simple buzzer that start and stops every one second.
Components
For this project, we need the following components:
- Arduino Uno board (1 pc.)
- KY-012 Active Buzzer Module (1 pc.)
- Jumper wires
Wiring Diagram
Figure 2 shows the connection between the Arduino Uno and the KY-012 Active Buzzer Module.
The KY-012 module pins are connected to the Arduino Uno board as follows:
Component Pin | Arduino Uno board Pin |
---|---|
(-) | GND |
middle | No connection |
S | 8 |
The Code
Below is the Arduino sketch for our project. I have added comments to explain important parts of the code. Save the code as KY-012.ino and upload it to your Arduino board.
// Arduino and KY-012 module
void setup()
{
pinMode (8, OUTPUT);
}
void loop()
{
digitalWrite (8, HIGH); // switch on buzzer
delay (1000); // wait 1 second
digitalWrite (8, LOW); // switch off buzzer
delay (1000);
}
Project Test
Apply power to your Arduino Uno board. The KY-012 will sound for one second, stop for one second and this cycle repeats indefinitely.