#include <Wire.h> // Include the Wire library for I2C communication
#include <LiquidCrystal_I2C.h>
#define LDR_PIN A0 // Change LDR_PIN to the appropriate analog pin for your LDR
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
pinMode(LDR_PIN, INPUT);
lcd.init();
lcd.backlight();
lcd.begin(20, 4); // Initialize LCD screen for 20x4 display
}
void loop() {
int ldrValue = analogRead(LDR_PIN); // Read LDR value
lcd.clear(); // Clear the LCD display before printing new values
lcd.setCursor(0, 0);
lcd.print("LDR Value: ");
lcd.print(ldrValue);
lcd.setCursor(0, 1);
lcd.print("Room: ");
if (ldrValue < 500) { // Adjust threshold based on your LDR
lcd.print("Dark ");
} else {
lcd.print("Light!");
}
delay(100); // Adjust delay as necessary
}