What are custom characters?
How custom characters are made and displayed on 16×2 lcd?
16×2 lcd has an internal CG-RAM(character generated ram) in which we can generate or place our custom character. CG-RAM size is 64 bytes. We can generate/place 8 characters of size 5×8 at a time in CG-RAM. We can also place 5×10 size characters in CG-RAM but only 4.
5×8 represents the dimension of the matrix in which a particular character can be displayed. 5 represents the number of coulombs and 8 represents the number of rows. 5×8 combined is a matrix size. Matrix is composed of pixels which we turn on and off to represent or make a character. For example to display a smiley 🙂 in 5×8 dimension individual pixels on and off will be same like below.
- Each switched on pixel binary value is ‘1‘.
- Each switched off pixel binary value is ‘0‘.
I almost explained every thing above, about generating custom characters in 16×2 lcd CG-RAM and displaying them on lcd screen. But still their are few things which are not part of this tutorial. Like custom character address in CG-RAM. Its because the arduino ide has pre-defined library which places the custom characters in CG-RAM and call it when needed for display. If you want to know about whats happening behind the library then irecommend you to please learn about the custom character generation in internal hardware level first before proceeding.
Arduino custom characters displayed on 16×2 lcd – Circuit diagram
- LCD RS pin to digital pin 13 of arduino uno
- LCD Enable pin to digital pin 12 of arduino uno
- LCD D4 pin to digital pin 11 of arduino uno
- LCD D5 pin to digital pin 10 of arduino uno
- LCD D6 pin to digital pin 9 of arduino uno
- LCD D7 pin to digital pin 8 of arduino uno
Arduino custom character display – Project code
The createChar() command in ardunio ide is very important. It creates/puts the character matrix/array against an addres in CG-RAM of 16×2 lcd. In other microcontrollers we have to write the memory address where we want to place our newly created custom character but in ardunio the createChar() command creates the required character automatically and place it against an address in CG-RAM. createChar() function is part of LiquidCrystal library. If we open the library and see the function statements they are communicating with the HD44780 lcd controller and CG-RAM address are defined in the function.
Arduino code steps to create and display custom characters on 16×2 lcd
The above statement is a byte array of a custom character in binary format.
lcd.createChar(2 , a);
The above command places the a byte array custom character against address 2 in CG-RAM. Real address is different its not 2 see library for real address.
The above command displays the custom character placed against the address 2 in CG-RAM.