Display Custom Characters on 16×2 LCD using Arduino

In this tutorial, we will display the custom characters on an LCD 16×2. Liquid crystal display (LCDs) offer a convenient and inexpensive way to provide a user interface for a project.

By far the most popular LCD used is the text panel based on the Hitachi HD44780 chip. This displays two or four lines of text, with 16 or 20 characters per line (32 and 40 character versions are also available, but usually at much higher prices).

We want to define and display custom characters or symbols (glyphs) that we have created. The symbols we want to display are not predefined in the LCD character memory.

A library for driving text LCD displays is provided with Arduino, and you can print text on your LCD easily as on the serial monitor because of LCD and serial share the same underlying print function.

Must See:


Components Needed


About LCD 16×2 Dot Matrix

To display custom characters on LCD, we must first know about the LCD dot matrix means pixels in LCD. There are 5 pixels in rows and 8 pixels in columns means every character is a combination of 5*8 dots.

The LiquidCrystal library enables you to create up to eight custom characters, which can be printed as character codes 0 through 8. Each character on the screen is drawn on a grid of 5 x 8 pixels.

To define a character, you need to create an array of eight bytes. Each byte defines one of the rows in the character. When written as a binary number, the 1 indicates a pixel is on, 0 is off (any values after the fifth bit are ignored).

custom characters on lcd

Custom Characters Pattern Code

S.NO:

Custom Character

Pattern Code

1

0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000

2

0b00000, 0b01010, 0b00000, 0b00000, 0b10001, 0b01110, 0b00000, 0b00000

 

Simply put “0” on the un-shaded place and “1” on the shaded place for each byte.

You also can generate the pattern code using the Custom Code Generator.


Circuit Diagram for Custom Characters on LCD

Circuit Diagram for Custom Characters on LCD

Reference:- Interfacing an LCD 16×2 with Arduino.


Code

The following code creates customs characters on the LCD.


Displaying Large Font / Double Height Characters

Now We want to combine two or more custom characters to print larger fonts / double-height characters than a single character; for example, double-height numbers on the screen.

large font on lcd display 16x2

Code for Double Height Characters

The LCD display has fixed-size characters, but you can create larger symbols by combining characters. This recipe creates five custom characters.

The glyphs array defines pixels for the five custom characters. The array has two dimensions given in the square brackets:

byte glyphs[5][8] ={...

[5] is the number of glyphs [8] is the number of rows in each glyph. Each element contains 1s and 0s indicate whether a pixel is on or off in that row. If you compare the values in glyph[0] (the first glyph), you can see that the 1s correspond to dark pixels:

{B11111,B11111,B00000,B00000,B00000,B00000,B00000,B00000},

Each big number is built from six of these glyphs, three forming the upper half of the big digit and three forming the lower half. BiDigitsTop and bigDigitsBot are arrays defining which custom glyph is used for the top and bottom rows on the LCD screen.


Some More Articles For You:

Scroll to Top