#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD address to 0x27 for a 20 chars and 4 line display
#define RED_PIN 5
#define GREEN_PIN 4
#define BLUE_PIN 3
#define PHOTO_PIN A0
void setup() {
// Initialize LCD
lcd.init();
lcd.backlight(); // Turn on the backlight
lcd.setCursor(4, 1);
lcd.print("Welcome to");
lcd.setCursor(0, 2);
lcd.print("Auto Adjust Light");
delay(2000);
lcd.clear();
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
}
void loop() {
// Read the analog value from the photoresistor
int sensorValue = analogRead(PHOTO_PIN);
// Display raw sensor value on LCD
lcd.setCursor(0, 1);
lcd.print("Sensor Value: ");
lcd.print(sensorValue);
// Set the RGB LED color based on the sensor value
analogWrite(RED_PIN, sensorValue / 4);
analogWrite(GREEN_PIN, sensorValue / 4);
analogWrite(BLUE_PIN, sensorValue / 4);
delay(200); // Delay for stability
lcd.clear();
}