#include <LiquidCrystal.h>
// Define LCD pin connections: RS, EN, D4, D5, D6, D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 6);
int sensorPin = A0;
int ldrValue = 0;
float lux = 0;
const float MAX_LUX = 100000.0;
const int MAX_ADC_VALUE = 1023;
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LDR Value");
}
void loop()
{
ldrValue = analogRead(sensorPin);
lux = (ldrValue * MAX_LUX) / MAX_ADC_VALUE;
lcd.setCursor(0, 1);
lcd.print("Lux: ");
lcd.print(lux);
lcd.print(" ");
delay(500);
}