int SwitchState=0;
void setup(){
pinMode(13, INPUT);//The button activating the siren and lights is an input
pinMode(12, OUTPUT);//the red light is an output
pinMode(11, OUTPUT);//the blue lught is an output
pinMode(10, OUTPUT);//the buzzer is also an output
}
void loop()
{
SwitchState = digitalRead(13);//The switchstate is the reading of the button
if (SwitchState ==LOW){ //if the switch is off
digitalWrite(12, LOW);//light off
digitalWrite(11, LOW);//light off
}
else {
digitalWrite(12, HIGH);//light on
digitalWrite(11, LOW);//light off
tone(10, 659.25);//high pitched tone
delay(500);//wait half second
digitalWrite(12, LOW);//light off
digitalWrite(11, HIGH);//light on
tone(10, 329.63);//low pitched tone
delay (500);//wait half a second
noTone(10);//if button is not pressed there should be no sound
}
}