#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD I2C address (usually 0x27 or 0x3F) and LCD size
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Photodiode analog output pin
const int photodiodePin = A0;
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.setCursor(0, 0);
lcd.print("Light Intensity:");
}
void loop() {
int rawValue = analogRead(photodiodePin);
int lightValue = 1023 - rawValue; // Invert so more light = higher number
lcd.setCursor(0, 1);
lcd.print("Level: ");
lcd.print(lightValue);
lcd.print(" "); // Clear leftover digits
delay(500); // Update twice per second
}