#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 or 0x3F depending on your module
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define custom character data. Each character is 8 bytes (8x8 pixel).
byte chr[8][8] = {
{
0x01,
0x03,
0x07,
0x0F,
0x1F,
0x03,
0x03,
0x03
},
{
0x18,
0x18,
0x18,
0x18,
0x18,
0x18,
0x18,
0x18
},
{
0x00,
0x00,
0x00,
0x03,
0x03,
0x03,
0x1F,
0x1F
},
{
0x00,
0x00,
0x00,
0x18,
0x18,
0x18,
0x1F,
0x1F
},
// |||||||||||||||||||||||||||||
{
0x03,
0x03,
0x03,
0x03,
0x03,
0x03,
0x1F,
0x1F
},
{
0x18,
0x18,
0x18,
0x18,
0x18,
0x18,
0x1E,
0x1E
},
{
0x1F,
0x1F,
0x03,
0x03,
0x03,
0x00,
0x00,
0x00
},
{
0x1F,
0x1F,
0x18,
0x18,
0x18,
0x00,
0x00,
0x00
}
};
byte chr1[8][8] = {
{
0x07,
0x0F,
0x1C,
0x18,
0x18,
0x1C,
0x0F,
0x07
},
{
0x1C,
0x1E,
0x07,
0x03,
0x03,
0x07,
0x1E,
0x1C
},
{
0x00,
0x00,
0x00,
0x00,
0x00,
0x07,
0x07,
0x00
},
{
0x00,
0x00,
0x00,
0x00,
0x00,
0x1C,
0x1C,
0x00
},
// |||||||||||||||||||||||||||||
{
0x07,
0x0F,
0x1C,
0x18,
0x18,
0x1C,
0x0F,
0x07
},
{
0x1C,
0x1E,
0x07,
0x03,
0x03,
0x07,
0x1E,
0x1C
},
{
0x00,
0x07,
0x07,
0x00,
0x00,
0x00,
0x00,
0x00
},
{
0x00,
0x1C,
0x1C,
0x00,
0x00,
0x00,
0x00,
0x00
}
};
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on backlight
// Create custom characters
for (int i = 0; i < 8; i++) {
lcd.createChar(i, chr[i]);
}
// Display custom characters in the first row
for (int i = 0; i < 4; i++) {
lcd.setCursor(i, 0); // Set cursor to the first row
lcd.write(i); // Display custom character
}
// Display custom characters in the second row
for (int i = 4; i < 8; i++) {
lcd.setCursor(i - 4, 1); // Set cursor to the second row
lcd.write(i); // Display custom character
}
}
void loop() {
// Nothing to do here
}