#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD with the I2C address (usually 0x27 or 0x3F) and dimensions
LiquidCrystal_I2C lcd(0x27, 16, 2);
unsigned long previousMillis = 0;
const long interval = 1000; // 1 second
int messageIndex = 0;
// Array of messages to display
const char *messages[] = {
"Dynamic Updates!",
"Hello, ayisha",
"Goodbye, 2024",
"innovative 2025",
};
void setup() {
// Begin I2C with GPIO 7 (SDA) and GPIO 6 (SCL)
Wire.begin(7, 6);
// Initialize the LCD
lcd.init();
lcd.backlight();
// Display the initial message
lcd.setCursor(0, 0);
lcd.print("Starting...");
delay(2000); // Brief delay to show the startup message
lcd.clear();
}
void loop() {
unsigned long currentMillis = millis();
// Update the message every 'interval' milliseconds
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
// Clear the LCD and display the next message
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(messages[messageIndex]);
// Move to the next message
messageIndex = (messageIndex + 1) % (sizeof(messages) / sizeof(messages[0]));
}
}