The 16x2 character LCD can also be used to display custom characters other than numerals, alphabets & special characters. Refer LCD interfacing with PIC. Some special shapes like hearts, arrows, smileys etc. can easily be displayed on the 5x8 pixel pattern of character LCD. These shapes are first stored at a special location in LCD’s controller and then displayed on the LCD module. This procedure has been explained here by using PIC18F4550.
The special characters are generated by bit-mapping of LCD’s 5×8 bit pixel matrix. Refer Creating custom characters on LCD using 8051 for more details on bitmap generation and storing custom values in custom generator (CG) RAM of LCD’s controller.

2. Select 5×7 + cursor line font and start filling the pixels in the matrix by clicking on them to create a custom character. The following figure depicts the generation of heart shape’s bitmap.



ASCII Code
|
Base Address
|
0
|
64
|
1
|
72
|
2
|
80
|
3
|
88
|
4
|
96
|
5
|
104
|
6
|
112
|
7
|
120
|
Fig. 6: Bitmap value address of custom character stored in CGRAM of LCD controller module
Project Source Code
###
// Program to display custom characters on 16x2 LCD using PIC18F4550 Microcontroller // Configuration bits /* _CPUDIV_OSC1_PLL2_1L, // Divide clock by 2 _FOSC_HS_1H, // Select High Speed (HS) oscillator _WDT_OFF_2H, // Watchdog Timer off MCLRE_ON_3H // Master Clear on */ //LCD Control pins #define rs LATA.F0 #define rw LATA.F1 #define en LATA.F2 //LCD Data pins #define lcdport LATB void lcd_ini(); void lcdcmd(unsigned char); void lcddata(unsigned char); void special_char(unsigned char, unsigned char, unsigned char *); unsigned char data1[]={10,21,17,17,17,10,4,0}; // Bitmap values of "heart" shape unsigned char data2[]={12,18,1,2,4,8,0,8}; unsigned char data3[]={1,3,5,9,9,11,27,24}; unsigned int i=0; void main(void) { TRISA=0; // Configure Port A as output port LATA=0; TRISB=0; // Configure Port B as output port LATB=0; lcd_ini(); // LCD initialization special_char(64,0x82,data1); // Function call to store "Heart" shape's bitmap at 64th base address // and print it at 0x82 location on LCD Delay_ms(1000); special_char(72,0x84,data2); Delay_ms(1000); special_char(80,0x86,data3); } void special_char(unsigned char cgram_loc, unsigned char lcd_loc, unsigned char *data) { unsigned int j=0; lcdcmd(cgram_loc); // Send location of CGRAM while(j<8) { lcddata(data[j]); // Send bitmap values of the character j++; } lcdcmd(lcd_loc); // Send LCD location where the character is to displayed lcddata((cgram_loc-64)/8); // ASCII value of corresponding base address } void lcd_ini() { lcdcmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5x7 font lcdcmd(0x0C); // Display On and Cursor Off lcdcmd(0x01); // Clear display screen lcdcmd(0x06); // Increment cursor lcdcmd(0x80); // Set cursor position to 1st line, 1st column } void lcdcmd(unsigned char cmdout) { lcdport=cmdout; //Send command to lcdport=PORTB rs=0; rw=0; en=1; Delay_ms(10); en=0; } void lcddata(unsigned char dataout) { lcdport=dataout; //Send data to lcdport=PORTB rs=1; rw=0; en=1; Delay_ms(10); en=0; }
###
Circuit Diagrams
Project Components
Project Video
Filed Under: PIC Microcontroller
Filed Under: PIC Microcontroller
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.