Sound an Alarm(Buzzer) CloudX
Buzzers are electrical signaling device that are used to make sound alerts in our projects/systems. It is a very small (though comes in different sizes) 2-pin component that can fit in on a breadboard.
A buzzer can be powered from a DC source of about 4v – 9v, which means it can be used directly with a 9v battery but it is recommended to use 5v most times. The buzzer actually gives a sound when HIGH which means 5v and sound stops when disconnected or LOW which means 0v on the positive terminal.
It has a wide application in electronics such as alarming circuits, automobiles, communication equipment, and portable devices due to its compact size.
The project above shows the buzzer positive (+) terminal connected to P1 on the microcontroller and the negative terminal (-) is connected to GND. Now, we will write a code to turn ON the alarm every one second.
In the program below, the buzzer will continue to give an ON and OFF sound forever because it’s written inside a loop. The sound will stop only when power is disconnected, the beauty about this project is that it has a very wide application in technology. Later in this book, we will design a tone generator for music using the buzzer.