Now it's look good to read.
void setup ()
{
lcd.begin(16,2);
pinMode(Relay, OUTPUT);
pinMode(AuxRelay, OUTPUT);
Serial.begin(9600);
}
// Main Program - This will run thru continously until power is disconnected or reset button is pressed.
void loop()
{
TurnMeOn();
delay(50); // Delay for LCD display
}
void TurnMeOn(){
int Power = analogRead(A4);
Serial.print(LDR);
Serial.println(Power);
if (Power > 700 && LastState == HIGH)
{
LDR = analogRead(A5);
analogWrite(BackLight, LDR / 2);
lcd.setCursor(0,0);
lcd.print("section else if");
if ( Power > 700 && LastState == LOW )
{
analogWrite(BackLight, 200);
lcd.clear();
lcd.print(" BLACKSNAKE SYS ");
lcd.setCursor(0,1);
lcd.print("DBC MARK 4, Ver1");
LastState = HIGH;
delay(2000);
lcd.clear();
if ( Power < 500 )
{
analogWrite(BackLight, 0);
LastState = LOW;
}
}
}
}
Is this is full source code?
"YES" then first you face error
"NO".
You use nested IF and if result of first one if (Power > 700 && LastState == HIGH) false
it never enters to execute all other statements.
Tarce the values of Power and LastState.