#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud rate
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.print("Waiting for data"); // Initial message
}
void loop() {
if (Serial.available() > 0) {
lcd.clear(); // Clear the LCD
String data = Serial.readString(); // Read the incoming data as a string
lcd.print(data); // Print the data to the LCD
}
}