#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcdSatu(0x27, 16, 2);
const int pinLdr = 25;
const int pinLed = 26;
void setup() {
lcdSatu.init();
lcdSatu.backlight();
pinMode(pinLdr, INPUT);
pinMode(pinLed, OUTPUT);
}
void loop() {
int ldr = analogRead(pinLdr); // baca nilai analog
lcdSatu.setCursor(0,0);
lcdSatu.print("LDR: ");
lcdSatu.print(ldr);
lcdSatu.setCursor(0,1);
if(ldr < 2000){ // jika nilai analog kurang dari 2000
lcdSatu.print("Siang");
digitalWrite(pinLed, LOW);
} else {
lcdSatu.print("Malam");
digitalWrite(pinLed, HIGH);
}
delay(200); // this speeds up the simulation
}