#include <LiquidCrystal.h>
#include <CapacitiveSensor.h>
const int Relay = 8;
const int AuxRelay = 7;
const int BackLight = 6;
int MainVolts = 0;
int AuxVolts = 0;
int LDR = 0;
int LastState = LOW;
void setup ()
{
lcd.begin(16,2);
pinMode(Relay, OUTPUT);
pinMode(AuxRelay, OUTPUT);
}
// 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);
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();
}
else if (Power > 700 && LastState == HIGH)
{
LDR = analogRead(A5);
analogWrite(BackLight, LDR / 2);
lcd.setCursor(0,0);
lcd.print("section else if");
}
else if ( Power < 500 )
{
analogWrite(BackLight, 0);
LastState = LOW;
}
}
Yes, it's seem good
One point that i add if elseif elseif to it because there is no need to check every "IF" if one of them true.