#include <LiquidCrystal.h>
// LCD pins <--> Arduino pins
const int RS = 11, EN = 12, D4 = 2, D5 = 3, D6 = 4, D7 = 5;
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);
int Delay = 100;
byte customChar0[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
0b00000
};
void setup()
{
lcd.begin(16, 2); // set up number of columns and rows
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("The Heart Moves!");
lcd.createChar(0, customChar0);
lcd.setCursor(0, 1); // move cursor to (2, 0)
lcd.write((byte)0); // print the custom char 0 at (2, 0)
}
void loop()
{
for (int position = 0; position < 16; position++) {
lcd.setCursor(position, 1); // Setting cursor to current position
lcd.write((byte)0); // Writing the heart character
delay(Delay);
lcd.setCursor(position, 1); // Setting cursor to current position
lcd.print(" "); // Clearing the heart character by printing space
}
// Move the heart from right to left
for (int position = 15; position >= 0; position--) {
lcd.setCursor(position, 1); // Setting cursor to current position
lcd.write((byte)0); // Writing the heart character
delay(Delay);
lcd.setCursor(position, 1); // Setting cursor to current position
lcd.print(" "); // Clearing the heart character by printing space
}
}