Piezo I





void setup() {

}

void loop() {

  tone(8, 440, 500);

  delay(1000);

}




siren

void setup() {

}

void loop() {

  for(int i=500; i<2000; i+=10) {
    note(i, 50);
  }
  for(int i=2000; i>500; i-=10) {
    note(i, 50);
  }
}

void note(int pitch, int duration) {
  tone(8, pitch, duration);
  delay(duration*0.8);
}