#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int photoresistorPin = A0;
const int indicatorPin = 13;
#define Buzz 2
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD I2C address and dimensions
void setup() {
lcd.begin(20, 4);
lcd.backlight(); // Turn on the LCD backlight
pinMode(indicatorPin, OUTPUT);
pinMode(Buzz, OUTPUT);
noTone(Buzz);
}
void loop() {
int sensorValue = analogRead(photoresistorPin);
// Adjust the threshold value based on your environment and sensor characteristics
int threshold = 500;
if (sensorValue > threshold) {
digitalWrite(indicatorPin, HIGH); // Turn on the LED indicator
lcd.setCursor(0, 0);
lcd.print("Light: Bright");
tone(Buzz,500);
delay(500);
} else {
digitalWrite(indicatorPin, LOW); // Turn off the LED indicator
lcd.setCursor(0, 0);
lcd.print("Light: Dim ");
noTone(Buzz);
}
lcd.setCursor(0, 1);
lcd.print("Sensor Value: ");
lcd.print(sensorValue);
delay(500);
}