#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define LDR_PIN 15 // Analog pin connected to LDR
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust the address if necessary
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Light Intensity:");
Serial.begin(115200); // Optional for debugging
}
void loop() {
int ldrValue = analogRead(LDR_PIN); // Read LDR value (0-4095)
// Convert to voltage (ESP32 ADC is 12-bit, 3.3V reference)
float voltage = (ldrValue / 4095.0) * 3.3;
// Display LDR value on LCD
lcd.setCursor(0, 1);
lcd.print("LDR: ");
lcd.print(voltage);
lcd.print(" V "); // Update value in volts
delay(1000); // Delay for 1 second
}