I am new to the Audrino world - just purchased my first board - a UNO - and writing a program for an alarm system in my workshop which is a separate building a few hundred feet from out house. Have been broken into twice over the last 10 years and many of my tools stolen. I am installing cameras along with magnetic switches on all doors and motion alarms in several areas.
I have wanted to try using an Audrino board for a while and figured this would be a good project to start with. I want to use an Audrino UNO to activate flashing lights and a siren in various configurations depending how long the alarm continues.
The following code is my first attempt at writing Audrino code. After running verify/compile several times and cleaning up some typos and minor coding errors I am stuck on an error in the lat line of the code. I keep getting an error "expected '}' at end of input. I tired many variations of the last line and use of brackets but no luck. FYI the intent of the last line is to hold the program indefinitely (do nothing) at this point till the alarm input goes to LOW.
Appreciate any help or suggestions, thanks Gary
int RedLite = 4;
int Siren = 7;
int Level1 = 8;
int Alarm = 2;
void setup() {
// put your setup code here, to run once:
pinMode(RedLite, OUTPUT);
pinMode(Siren, OUTPUT);
pinMode (Level1, OUTPUT);
pinMode(Alarm, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Level 1 Alarm - Flashing Red lights for 15 seconds
if (digitalRead(Alarm) == HIGH) { //Check if Alarm is activate or this will
//be false and not run }
{ for (int x = 0; x < 15; x++) //Repeat 15 times
digitalWrite(RedLite, HIGH); //Blink Red Lights on
delay(500); //for 500ms
digitalWrite(RedLite, LOW); //Blink Red Lights off
delay(500); //for 500ms
digitalWrite (Level1, HIGH); //Set Level1 Alarm to be used in Level2
delay(10);
}
//Level 2 Alarm - Flashing Red Lights and Siren doe 3 minutes
if (digitalRead(Alarm) == HIGH && digitalRead(Level1) == HIGH) {
//Check if alarm is active and Level1 was on
//or else this loop will be false and will not run
for (int y = 0; y < 360; y++){ //Repeat 360 times
digitalWrite(Siren, HIGH); //Turn on Siren
digitalWrite(RedLite, HIGH); //Blink Red Lights on
delay(250); //for 250ms
digitalWrite(RedLite, LOW); //Blink Red Lights off
delay(250); } //for 250ms
}
//Level 3 Alarm - Solid Red Lights for 46 Minutes
if (digitalRead(Siren) == HIGH) { //Check is Siren on to confirm Level2 was on
//or else this loop will be false and not run
digitalWrite(Siren, LOW); //Turn off Siren
digitalWrite(RedLite, HIGH); //turn Red Lights on solid
delay(10000000); //delay for 46 minutes
digitalWrite(RedLite, HIGH); //Turn Red lights off
digitalWrite(Level1, LOW); //Turn Level1 Status off
}
if (digitalRead(Alarm) == HIGH) { //Do nothing as long as Alarm stays High
}