Experiencing an "else' without a previous 'if'" problem. when it has an 'if'

Hi,

I'm experiencing an error I couldn't fix and I need help on how to just correct the error.

So as you can see from the title, I'm experiencing an "else' without a previous 'if'" problem.

and I am having this error on the 2nd last line where it says...

"else digitalWrite(LED, LOW); // Turn the LED off"

Thank You in Advance for the help.

ALARM_SYSTEM..ino (646 Bytes)

read this please;

Syntax problem. Your current code:

if(digitalRead(sensor)== HIGH);         
    delay(5000);                           // 5 Seconds Before Alarm Sounds
             {if(digitalRead(sensor)== HIGH);
                digitalWrite(LED, HIGH);   // Turn the LED on   
           else digitalWrite(LED, LOW);    // Turn the LED off
             }          
else digitalWrite(LED, LOW);               // Turn the LED off

makes no sense. Do you understand the use of '{' and '}'?

What do you want to happen if "sensor" is high?

Something like this?

   if(digitalRead(sensor)== HIGH)
    {   
        delay(5000);                           // 5 Seconds Before Alarm Sounds
        digitalWrite(LED, HIGH);   // Turn the LED on   
    }          
    else 
        digitalWrite(LED, LOW);               // Turn the LED off

More studying of the language required.