/*
Photoresistor (LDR) Analog Demo
Copyright (C) 2021 Uri Shaked.
https://wokwi.com/arduino/projects/305193627138654786
*/
#include <LiquidCrystal_I2C.h>
#define LDR_PIN 14
// LDR Characteristics
const float GAMMA = 0.7;
const float RL10 = 50;
int lux=0;
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(LDR_PIN, INPUT);
lcd.init();
lcd.backlight();
}
void loop() {
lcd.setCursor(2, 0);
if (digitalRead(LDR_PIN)==LOW){
int lux=0;
lcd.print("Dark ");
}else{
int lux=1;
lcd.print("Light!");
}
lcd.setCursor(0, 1);
lcd.print("Lux: ");
lcd.print(lux);
lcd.print(" ");
delay(100);
}