//lcd setup
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//creates the custom character
byte arrow[8] = {
B01110,
B01010,
B01010,
B01010,
B10001,
B01010,
B00100,
};
//defining variables
int button = 13;
int previousButtonState= 0;
//setup for lcd and digital pin
void setup()
{
lcd.begin(16, 0);
pinMode(button, INPUT);
lcd.createChar(0, arrow);
}
void loop()
{
//variable checks if the button is pressed
int buttonState = digitalRead(button);
//clears lcd when button is released
if (previousButtonState != buttonState){
lcd.clear();
//when button is held the heart is displayed
if (buttonState == HIGH) {
lcd.write(byte(0));
}
//makes the current button state the previous one for the next loop iteration
previousButtonState = buttonState;
}
}