Great to see your always so helpful and understand that not everyone is up to your standards...
Lots of things go wrong here, don't worry about that. ![]()
Cybernetician has a point. If you look at the way you have the code, LastState will never go high. Use the auto-indent tool, and it is more obvious:
void TurnMeOn(){
// Check the state of the Ignition and turn off backlight if off or PWM backlight and display company details.
int Power = analogRead(A4); // Check the state of the ignition pin and store the result in "power".
// Igniton is on - Control intensity of Backlight by reading the LDR and PWMing the Backlight.
if (Power > 700 && LastState == HIGH) // Checks to see if the Ignition is on by looking for more then 700 DAC counts
{ // Also checks Last State is HIGH (It has already displayed company logo.
LDR = analogRead(A5); // reads the DAC Counts from Analog 5 and stores the result in LDR.
analogWrite(BackLight, LDR / 2); // PWM's the backlight between 0 & 255.
lcd.setCursor(0,0); // Sets the Cursor to Position 1, Line 1.
lcd.print("power off"); // Prints to LCD
// Ignition has just been switched ON from the OFF state, We want to throw in a little advertising.
if ( Power > 700 && LastState == LOW )
{
analogWrite(BackLight, 200); // Sets the Backlight to 3/4 brightness for logo only.
lcd.clear(); // Clears the LCD display.
lcd.print(" BLACKSNAKE SYS "); // Prints whats in the brackets on the LCD display.
// Spaces 1234567890123456 , this is just to make sure we are using the correct number of characters available on the LCD.
lcd.setCursor(0,1); // Sets the cursor the the first position on line 2. (Character, Line (16,2)).
lcd.print("DBC MARK 4, Ver1"); // prints to LCD.
LastState = HIGH; // Stops this from occuring every loop.
delay(2000); // Delay's for 2 seconds whilst company logo is being displayed.
lcd.clear(); // Clears the display.
// If the ignition is switched off we will turn the backlight off to reduce theft factor.
if ( Power < 500 ) // Checks that the ignition is below 500 DAC counts.
{
analogWrite(BackLight, 0); // Sets the Backlight PWM to 0 (OFF)
LastState = LOW; // Sets state to LOW so logo is written when ignition is turned back on
}
}
}
}