Create Your Custom Character for LCD in Arduino
Was working on my wife’s Sparkfun Red Board. I had bought for her birthday 🎂. I think I am having more fun with it than her.
The first thing I wanted to do was to write I ♥ U
on the LCD, to show my lovely wife how an awesome thing the Arduino board is.
So the secret is creating a byte array. And using createChar()
which is a method of the LiquidCrystal library that Arduino.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2); // make some custom characters:
byte heart[8] = { 0b00000, 0b01010,
0b11111, 0b11111,
0b11111, 0b01110,
0b00100, 0b00000
};
byte smile[8] = { 0b00000, 0b00100,
0b10010, 0b00001,
0b10001, 0b00010,
0b00100, 0b00000
};
void setup() {
lcd.createChar(1, heart);
lcd.createChar(2, smile);
lcd.begin(16, 2);
//lcd.clear();
lcd.print("I ");
lcd.write(1);
lcd.print(" U");
lcd.write(2);
}
void loop() {
lcd.setCursor(0,1);
lcd.print(millis()/1000);
}
Have fun!