float sinVal;
int toneVal;
int k=0;
void setup () {
pinMode(8,OUTPUT);
}
void loop () {
while (k< 2000){
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);
k++;
delay(2);
}}
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(5);}
}
To make the siren sound different every 5 seconds you change the frequency to make a different sound and then you also change the delay to make it play a different sound. The higher the amplitude (the number in front of sin) the higher pitch the sound will be.
Heres the link for the video:
https://drive.google.com/a/slsharks.net/folderview?id=0B6Ep8JcC1gm_dmc0cDZoNklBUWM&usp=sharing&tid=0B6Ep8JcC1gm_UkhBZi1GUjBzalk
int toneVal;
int k=0;
void setup () {
pinMode(8,OUTPUT);
}
void loop () {
while (k< 2000){
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);
k++;
delay(2);
}}
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(5);}
}
To make the siren sound different every 5 seconds you change the frequency to make a different sound and then you also change the delay to make it play a different sound. The higher the amplitude (the number in front of sin) the higher pitch the sound will be.
Heres the link for the video:
https://drive.google.com/a/slsharks.net/folderview?id=0B6Ep8JcC1gm_dmc0cDZoNklBUWM&usp=sharing&tid=0B6Ep8JcC1gm_UkhBZi1GUjBzalk