Close

Arduino Workshop-Piezo Sounder Alarm

mr-sarful-hassanMr. Sarful hassan wrote 06/14/2020 at 16:26 • 3 min read • Like
Today in this project we are going to create a wailing alarm sound, By connecting a piezo sounder to a digital output pin this is very, this is a very simple project I will show you in this project step by step Required Component : 1.Arduino 2. Piezo Sounder
his book will help you to gain more knowledge about Arduino
Beginning Arduino Circuit diagram Arduino Piezo Sounder Alarm  : First, make sure your Arduino is powered off by unplugging it from the USB cable Then Connect up your Arduino Piezo Sounder Alarm  and connect your Arduino back to the USB cable and power it up  [caption id="attachment_439" align="alignnone" width="300"]Piezo Sounder Alarm Piezo Sounder Alarm[/caption] Code  :
float sinVal;
int toneVal;
void setup() {
pinMode(8, OUTPUT);
}
void loop() {
for (int x=0; x<180; x++) {
// convert degrees to radians then obtain sin value
sinVal = (sin(x*(3.1412/180)));
// generate a frequency from the sin value
toneVal = 2000+(int(sinVal*1000));
tone(8, toneVal);
delay(2);
}
}
Once you have uploaded the code, there will be a slight delay, and then your piezo will start to emit sounds. If everything is working as planned, you will hear a rising and falling siren-type alarm, similar to a car alarm. ALL ARDUINO TUTORIAL 
Like

Discussions