#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the library with the I2C address of your LCD (0x27 or 0x3F are common)
LiquidCrystal_I2C lcd(0x27, 16, 2);
byte heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000
};
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.createChar(0, heart); // Create a custom character
lcd.setCursor(0, 0); // Set the cursor to the first row
lcd.print(“I love you”); // Print “I love you”
}
void loop() {
for (int pos = 0; pos < 16; pos++) {
lcd.setCursor(pos, 1); // Set the cursor to the second row
lcd.write(byte(0)); // Write the heart character
delay(200); // Wait for 200 ms
lcd.setCursor(pos, 1); // Set the cursor again
lcd.print(“ “); // Clear the previous heart
}
}