My vehicle alarm consists of a control box containing some vibration sensor and relays, and a buzzer that creates an ear piercing sound upon triggering. I've recorded this alarm sound.
After pulling off the buzzer, I'm trying to replicate this sound on my Arduino Uno with it. Here is what my 'buzzer' looks like: High Decibels Alarm XHD SFB-55 DC6 12V Acoustic Alarm Buzzer Horn Siren.
To find the frequency function of the alarm sound I used Spek – Acoustic Spectrum Analyser:
This plot shows something that's close to saw tooth wave between the frequencies 2kHz and 5kHz.
After playing around with Wolfram Alpha to find a function description I get the following code:
for(double x = 0; x < 0.92; x += 0.01){
tone(3, sinh(x+8.294), 10);
delay(1);
}
for(double x = 0; x < 0.183258; x += 0.002){
tone(3, sinh(-5* (x-1.8420681)), 10);
delay(2);
}
This is how I connect the buzzer.
I suspect it's a piezo buzzer because when there is no R2, I only hear a click sound. I have read about capacitive behaviour of piezo buzzers, so adding R2 should be unload the buzzer.
The sound I get is quite close but it's far from ear piercing, but more like a sound of a bird.
I suspect the frequency function is not 'sharp' enough, does the function have to rise and drop quicker to create the original effect?
Could anybody help me with this function, or is there a better way to sound an alarm?