Tuesday, 27 January 2015

How to Display custom character on 16x2 LCD.

Displaying Custom character on 16x2 LCD

Here I am explaining how to display custom character on 16x2 LCD display. In alphanumeric 16x2 LCD display 64 bytes of CG (character generator) RAM is available to create custom character. Address of CG RAM is starts from 64 and ends to 127. Each character consists 8 bit so maximum 8 custom characters can be stored in CG RAM.

Now in my code firstly I have generated 8 custom characters and put it into CG RAM of LCD .Then after I have display these 8 characters starting from 1 position of first line with single space between each character.

Main Program to display custom character on 16x2 LCD with 5x7 pixels is given in images below :-



In above image you can see that I have created a array which contains 56 digit. So here first 7 digits is for first custom character which is a Bell then next 7 digits is for second custom character which is Heart then next 7 digits is for third custom character which is Smile then next 7 digits is for fourth custom character which is Symbol of Music then next 28 digits is for 4 Hindi Characters .You will say how I will explain in detail but first look on image given below which contain the main code:-


The code shown in image above is complete code of creating 8 custom character and display all these on 16x2 LCD.
So Here I will only explain how I create my first character Bell and display it on LCD the rest you’ll automatically understand.

Creating Custom Character:-

In above code after initializing LCD I have used a For loop for creating 8 custom character in that loop when we enter first time we’ll send a command 64 on LCD which is base address of CG RAM. Then I have send first 7 data using loop which are 4,14,14,14,31,0,4 to create Bell.

How this data creating Bell is a question? Answer of this question you will found below:-

16   8     4    2     1





    





























  
The above Figure shows the 5x7 pixel of LCD Block .Which pixel we wants to put ON we can do it with code. First I have send data 4 which is to ON 3rd  pixel of first row and then I have send 14,14,14 which put ON 2,3,4 pixel of 2,3,4 row and then I have send 31 to ON all 5 pixels of 5th row then 0 to OFF all 5 pixels of 6th row then after 4 to ON 3rd  pixel of seventh row. In this manner the picture which comes out is of Bell. So in this manner you can generate your own custom character.

Displaying Custom Character :-

After Creating all 8 characters I have display all these character using a for loop .In that loop first I have send command of start_add which is 0x80 to display character from 1 position of first line of 16x2 LCD. Then I have display the custom character which I have put in CG RAM for Ex I have put Bell on address 64-71. To characters which we have put in CG RAM can be display by sending data 0 for location 64, 1 for location 72 and …………….7 for location 120.

Through the above code the character that I have created is given in Image below:-


Read This :-
Before Reading this post First read How to display character on 16x2 LCD from my earlier post.

Download Link:-

To Download Complete code please click here. If you are unable to download this code then please give your email id in comment section.

No comments: