#include <LiquidCrystal.h>
// Initialize the LCD with the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Custom character arrays
// Smiley Face
byte smiley[8] = {
B00000,
B01010,
B00000,
B00000,
B10001,
B01110,
B00000,
B00000
};
// Heart
byte heart[8] = {
B00000,
B01010,
B11111,
B11111,
B01110,
B00100,
B00000,
B00000
};
// Star
byte star[8] = {
B00100,
B01110,
B11111,
B01110,
B11111,
B01110,
B00100,
B00000
};
// Arrow
byte arrow[8] = {
B00100,
B01100,
B11111,
B01100,
B00100,
B00000,
B00000,
B00000
};
void setup() {
lcd.begin(16, 2); // Initialize a 16x2 LCD
// Create the custom characters in LCD memory
lcd.createChar(0, smiley); // Store the smiley face at location 0
lcd.createChar(1, heart); // Store the heart at location 1
lcd.createChar(2, star); // Store the star at location 2
lcd.createChar(3, arrow); // Store the arrow at location 3
lcd.clear(); // Clear the LCD display
// Displaying custom characters on the LCD
lcd.setCursor(0, 0); // Position cursor at top-left
lcd.write(byte(0)); // Display smiley face
lcd.print(" Smiley");
lcd.setCursor(0, 1); // Move to start of the second row
lcd.write(byte(1)); // Display heart
lcd.print(" Heart");
lcd.setCursor(8, 0); // Position cursor in the middle of first row
lcd.write(byte(2)); // Display star
lcd.print(" Star");
lcd.setCursor(8, 1); // Move to middle of the second row
lcd.write(byte(3)); // Display arrow
lcd.print(" Arrow");
}
void loop() {
// No animation in this example; characters are statically displayed
}