It's very hard to know from your question what you are having trouble with. I have a piano and I can hit the keys, but it takes me a long time to hit them in the right order and with the right timings to create a new symphony.
Anyway, if creating the sounds is the problem, have you looked at the Tone library?
Different alarms have different sounds. I once heard an alarm which sounded like the start of Fuer Elise, so probably the notes were E
and D#
. That would make their frequencies about 330Hz and 311Hz:
void loop()
{
tone(pin, 330, 250);
delay(300);
tone(pin, 311, 250);
delay(300);
}
The sound you linked to sounds to me like it starts on a C, and slides up gradually one octave. One octave higher is double the frequency, so this code should do that:
void loop()
{
const int startFreq = 523; // C5 is 523Hz
// Start at the given freqency, and increase gradually by
// one octave (double the frequency)
for (int freq=startFreq ; freq<= (startFreq*2) ; ++freq)
{
tone(pin, freq, 10);
delay(3);
}
}