Arduino siren sound generator code

Here a simple Arduino code to generate a wailing audio tone. The code can be used to generate tones similar to a police siren, ambulance siren, warning sirens, etc.
This circuit works using the tone function of the Arduino. The tone() function generates a square wave with the given frequency at the specified pin.
arduino tone generator, arduino siren
 In order to generate a wailing sound, two for loop are used in the program to modulate the frequency; one (for loop) for to increment from lower to a higher frequency and another one(for loop) to decrement from higher to a lower frequency. In the given program the output frequency range is between 700-800 HZ.
The sound effect of the siren can be modified by varying the frequency range, the time delay, also by additional modulation of frequency and time contents. With a precise tuning and code adjustments, we can experiment various effects of sound.

Arduino siren code

int i=0;
void setup() {
  pinMode(9, OUTPUT);
}

void loop() {
  for(i=700;i<800;i++){
  tone(9,i);
  delay(15);
  }
  for(i=800;i>700;i--){
  tone(9,i);
  delay(15);
  }
  }
1 Star2 Stars3 Stars4 Stars5 Stars Rate Us!
Loading...

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *