#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
// Custom character representing the heart shape
byte heartSymbol[8] = {
B00000,
B01010,
B11111,
B11111,
B11111,
B01110,
B00100,
B00000
};
const int maxLength = 16; // Maximum length of scrolling text
char text1[] = "Hello, World!"; // Text for the first row
char text2[] = "Goodbye!"; // Text for the second row
void setup() {
lcd.begin(20, 4);
// Create the heart symbol at position 0
lcd.createChar(0, heartSymbol);
// Display the heart symbol in full screen
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 20; col++) {
lcd.setCursor(col, row);
lcd.write(0); // Display the heart symbol
}
}
}
void loop() {
static int offset1 = 0; // Scrolling offset for the first row
static int offset2 = 0; // Scrolling offset for the second row
lcd.setCursor(2, 1); // Set cursor position for the first row
// Print scrolling text for the first row
for (int i = 0; i < maxLength; i++) {
lcd.print(text1[(i + offset1) % strlen(text1)]);
delay(200); // Adjust the scrolling speed here
lcd.setCursor(2, 1); // Reset cursor position for next character
lcd.print(" "); // Clear the previous character
}
lcd.setCursor(3, 2); // Set cursor position for the second row
// Print scrolling text for the second row
for (int i = 0; i < maxLength; i++) {
lcd.print(text2[(i + offset2) % strlen(text2)]);
delay(200); // Adjust the scrolling speed here
lcd.setCursor(3, 2); // Reset cursor position for next character
lcd.print(" "); // Clear the previous character
}
offset1++; // Update the scrolling offset for the first row
offset2++; // Update the scrolling offset for the second row
}