Custom Characters for LCD module
This tutorial shows you how to make custom characters on both LCD modules. Custom characters can be handy when you can want to display something unique or characters not defined in ASCII codes.
Each character on the LCD panel is composed of 5x8=40 pixels. Different characters are formed by turning on the pixel at different positions at the same time.
Designing the character
Let's make a happy face character to illustrate how it looks like in a grid. Since the grid is narrow, we will make a simple happy face and keep it in the center as shown in the grid below. Note it is always a good idea to draw your character on the paper first, so you can see the end result and rearrange the pixel positions if needed.
Once we have designed the character, we are ready to use the LCD module. Both LCD2x16 and LCD4x20 modules have the CustChar() command which you can use to define your character like the happy face above. The syntax of the CustChar() is:
myLCD.CustomChar(Index, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)
where Index refers to the index of the characters. You can define up to eight custom characters,
To define our happy face, we will call the command like this:
myLCD.CustomChar(0, 0, 10, 10, 0, 4, 17, 14, 0)
Displaying the character
Once it is defined, you can call it using the DisplayChar() command as follow:
The argument in DisplayChar() command can be the index of the user defined character 0-7, or any character in ASCII format.
'display the happy face char with space (32 in ASCII code) in between
myLCD.DisplayChar(0, 32, 0, 32, 0)
For other commands, see the LCD Manual.
FAQ | Terms & Conditions | Contact Us