This was the code used to make an ambulance sound:
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);}
}
This is the link to our video of the ambulance sound:
https://drive.google.com/a/slsharks.net/#shared-with-me
To make the siren sounds we changed the frequency to make the different sounds and you also change the delay to make the sound either go faster or slower. If you were to change the amplitude, it would either make the sound higher or lower.
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);}
}
This is the link to our video of the ambulance sound:
https://drive.google.com/a/slsharks.net/#shared-with-me
To make the siren sounds we changed the frequency to make the different sounds and you also change the delay to make the sound either go faster or slower. If you were to change the amplitude, it would either make the sound higher or lower.