#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int led = 0;
const int ldr = A5;
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.begin(16, 2);
lcd.backlight();
pinMode(led, OUTPUT);
pinMode(ldr, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int nilaildr = analogRead(ldr);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Val.LDR:");
lcd.setCursor(9, 0);
lcd.print(nilaildr);
if (nilaildr > 400){
digitalWrite(led, HIGH);
lcd.setCursor(0, 1);
lcd.print("Night:ON");
} else {
digitalWrite(led, LOW);
lcd.setCursor(0, 1);
lcd.print("Day:OFF");
}
delay(3000);
}