#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address and the display size (16 columns and 2 rows)
String firstRowMessages[] = {"MANOK", "BABOY", "ISDA.", "IRO..", "GULAY"}; // Messages for the first row
String secondRowMessages[] = {"200KL", "280KL", "250KL", "300KL", "900KL"}; // Messages for the second row
int numMessages = sizeof(firstRowMessages) / sizeof(firstRowMessages[0]); // Number of messages
int currentMessageIndex = 0; // Index of the current message pair being displayed
int scrollSpeed = 900; // Speed of scrolling (lower value = faster scrolling)
int displayLength = 16; // Number of characters displayed on the LCD
int scrollPosition = 0; // Initial position of the scroll
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
// Display the initial rows
lcd.setCursor(0, 0); // Set the cursor to the beginning of the first row
lcd.print(firstRowMessages[currentMessageIndex]); // Print the initial message on the first row
lcd.setCursor(0, 1); // Set the cursor to the beginning of the second row
lcd.print(secondRowMessages[currentMessageIndex]); // Print the initial message on the second row
}
void loop() {
// Scroll the text
for (scrollPosition = 0; scrollPosition < displayLength; scrollPosition++) {
scroll();
delay(scrollSpeed);
}
// Reset the scroll position
scrollPosition = 0;
// Move to the next message
currentMessageIndex++;
if (currentMessageIndex >= numMessages) {
currentMessageIndex = 0; // Reset to the first message if reached the end
}
// Update the display with the new message
lcd.clear(); // Clear the display
lcd.setCursor(0, 0); // Set the cursor to the beginning of the first row
lcd.print(firstRowMessages[currentMessageIndex]); // Print the new message on the first row
lcd.setCursor(0, 1); // Set the cursor to the beginning of the second row
lcd.print(secondRowMessages[currentMessageIndex]); // Print the new message on the second row
}
void scroll() {
// Scroll both rows
lcd.scrollDisplayRight(); // Scroll the display to the right
}