#include <Wire.h>
//#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
#define LDR_PIN A5
#define RELAY_PIN 8
LiquidCrystal_I2C lcd(0x27, 20, 4);// ref: datashee
void setup() {
pinMode(RELAY_PIN, OUTPUT);
Wire.begin();
// put your setup code here, to run once:
lcd.begin(20, 4); // Initialize LCD COLUMN, ROW
lcd.backlight();
printLcd(0,0,"oM zrii gurave namaH");
printLcd(0,1,"17:50:00 05Jan2024");
printLcd(0,2,"Fri (7P) 22C (A)");
//printLcd(0,3,"next bell in 40 min");
}
void loop() {
int threshold = 500;
int lightValue = analogRead(LDR_PIN);
//if(analogRead(LDR_PIN) <= 20){digitalWrite(RELAY_PIN, HIGH);
//}else {digitalWrite(RELAY_PIN, LOW);}
if (lightValue < threshold) {
// It's dark, turn on the light
digitalWrite(RELAY_PIN, HIGH);
} else {
// It's bright, turn off the light
digitalWrite(RELAY_PIN, LOW);
}
printLcd(0, 3, "Range is -=> "+ String(lightValue));
delay(1000);
}
void printLcd (int shuru, int sesh, String myWords) { // For LCD Display
lcd.setCursor(shuru, sesh); lcd.print(myWords);
}