#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Create an instance of the LCD class
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int ldrPin = A0; // LDR connected to analog pin A0
const int ledPin = 13; // LED connected to digital pin 13
void setup() {
// Initialize the LCD
lcd.begin(16, 4);
lcd.print("LIGHT INTENSITY :");
pinMode(ledPin, OUTPUT);
}
void loop() {
int ldrValue = analogRead(ldrPin);
lcd.setCursor(2, 2);
lcd.print(ldrValue);
if (ldrValue < 500) {
digitalWrite(ledPin, HIGH); // Turn on the LED if LDR value is below 500
} else {
digitalWrite(ledPin, LOW); // Turn off the LED if LDR value is above 500
}
delay(500);
}