/*
*************************************************************************************
Concept to Apply On Road Light COntroller with LCD Display showing "Now its Dark" and
"Lights are On"
Similarly "Now Sun Rises" and "Lights are Off"
On Top Of LCD Line Scrolling Message "Electro Devices,Ajmer (Rajasthan)"
**************************************************************************************
*/
#include <SoftwareSerial.h>
#include <LiquidCrystal_I2C.h>
void createCustomCharacters();
void printFrame();
//defining House Icon
byte housechar1[8]={B00000, B00001, B00011, B00011, //Row 0, Col 0
B00111, B01111, B01111, B11111,};
byte housechar2[8]={B11111, B11111, B11100, B11100, //Row 1, Col 0
B11100, B11100, B11100, B11100,};
byte housechar3[8]={B00000, B10010, B11010, B11010, //ROW 0, Col 1
B11110, B11110, B11110, B11111,};
byte housechar4[8]={B11111, B11111, B11111, B10001, //Row 1, Col 1
B10001, B10001, B11111, B11111,};
LiquidCrystal_I2C lcd(0x27, 20, 4);
#define LDR A0 //Read the LDR value from the point where it meets the Resistor
int LedP = 7 ;
int LDR_Value;
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
delay(1000);
lcd.createChar(1,housechar1);
lcd.createChar(2,housechar2);
lcd.createChar(3,housechar3);
lcd.createChar(4,housechar4);
lcd.setCursor(0,0);
lcd.write(1);
lcd.setCursor(0,1);
lcd.write(2);
lcd.setCursor(1,0);
lcd.write(3);
lcd.setCursor(1,1);
lcd.write(4);
lcd.setCursor(3,0);
lcd.print("Electro ");
lcd.setCursor(3,1);
lcd.print("Devices AJMER ");
delay(10000);
lcd.clear();
pinMode(LDR, INPUT); // Analog hai,iss liye pull up na kare
pinMode(LedP, OUTPUT);
digitalWrite(LedP,LOW);
delay(5000);
lcd.clear();
}
void loop() {
LDR_Value=analogRead(LDR); // Constantly read and display the LDR value
lcd.setCursor(12, 0); // Ye Line Just Simulation k liye hai..Upload karte samay COMMENT kar de
lcd.print(LDR_Value); // Ye Line Just Simulation k liye hai..Upload karte samay COMMENT kar de
if (LDR_Value < 200) { // Sunset or If someone passes through the value will drop, 800 is the threshold, you can chose whatever suits you, the serial monitor will help you
digitalWrite(LedP, HIGH);
lcd.setCursor(0, 0);
lcd.print("It's Dark");
lcd.setCursor(0, 1);
lcd.print("Lights are On ");
}
else {
digitalWrite(LedP, LOW);
lcd.setCursor(0, 0);
lcd.print("Sun Rises");
lcd.setCursor(0, 1);
lcd.print("Power Saving On ");
}
}