#include <LiquidCrystal_I2C.h>
#define buzzer 6
const int col = 16; // Number of columns in the LCD
const int row = 2; // Number of rows in the LCD
LiquidCrystal_I2C lcd(0x27, col, row);
int position = 0; // Starting position for scrolling
String textLCD = "Filbert Alvino Miguel "; // Text to display
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
// Initial display setup
lcd.setCursor(0, 0);
lcd.print("Hello");
pinMode(buzzer, OUTPUT);
}
void loop() {
// Update the first line with a static message
lcd.setCursor(0, 0);
lcd.print("Hello");
tone(buzzer, 2550);
// Create a display string that wraps the text properly
String displayString = textLCD.substring(position) + textLCD.substring(0, position);
// Ensure the display string is exactly col characters long
displayString = displayString.substring(0, col);
// Update the second line with the scrolling text
lcd.setCursor(0, 1);
lcd.print(displayString);
noTone(buzzer);
// Increment the position for the scrolling effect
position += 1;
if (position >= textLCD.length()) {
position = 0;
}
delay(300); // Adjust the delay for desired scrolling speed
}