#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 columns, 2 rows
const int ldrPin = 2; // Pin connected to the LDR module
void setup() {
Serial.begin(9600);
pinMode(ldrPin, INPUT);
Wire.begin();
lcd.begin(16, 2);
lcd.backlight();
lcd.clear();
lcd.print("LiFi Project");
delay(3000);
lcd.clear();
lcd.print("Enter message:");
}
void loop() {
// Read LDR value
int ldrValue = analogRead(ldrPin);
// Map LDR value to a range suitable for printing
int mappedValue = map(ldrValue, 0, 1023, 0, 15);
// Read user input from Serial Monitor
if (Serial.available() > 0) {
String userInput = Serial.readString();
// Clear LCD and display user input
lcd.clear();
lcd.print(userInput);
// Wait for a moment to display the message
delay(2000);
// Clear LCD and prompt for the next input
lcd.clear();
lcd.print("Enter message:");
}
delay(200);
}