Somewhat new to arduino. Im currently building an alerting system for our fire house. Basic jist of what im doing is using the alert signal from a pager to trigger the system and close a series of relays and delay based on function of said relay. I have pasted the code below . The only part im looking for help on is if another alert comes in before all delays are satisfied I need the code to start over. The code currently works, however it will ignore any further input until all of the delays have completed. Thank you for any assistance.
}Use code tags to format code for the forum
int SOUND=10;
int ALERTLIGHT=9;
int BUNKLIGHT=8;
int SPEAKER=7;
int alert=2;
int sounddelay=3000;
int alertlightdelay=6000;
int bunkdelay=10000;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
pinMode (SOUND, OUTPUT);
pinMode (ALERTLIGHT, OUTPUT);
pinMode (SPEAKER, OUTPUT);
pinMode (BUNKLIGHT, OUTPUT);
pinMode (alert, INPUT);
digitalWrite (SOUND, HIGH);
digitalWrite (ALERTLIGHT, HIGH);
digitalWrite (BUNKLIGHT, HIGH);
digitalWrite (SPEAKER, HIGH);
digitalWrite (alert, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
byte inputPulse=digitalRead(alert);
if (inputPulse == HIGH){
digitalWrite (SOUND, LOW);
digitalWrite (ALERTLIGHT, LOW);
digitalWrite (BUNKLIGHT, LOW);
digitalWrite (SPEAKER, LOW);
delay(sounddelay);
digitalWrite (SOUND, HIGH);
delay(alertlightdelay);
digitalWrite (ALERTLIGHT, HIGH);
delay(bunkdelay);
digitalWrite (SPEAKER, HIGH);
digitalWrite (BUNKLIGHT, HIGH);
}
}