You are on page 1of 9

When the ASCII code for any character, say ‘A’, is sent to be displayed on LCD module, the module

's controller looks up the appropriate 5x8-pixel pattern in ROM (read-only memory) and displays that pattern on the LCD. There are 8 symbol locations where a custom character can be stored as shown in the following right table. These locations will have a particular bitmap layout corresponding to the custom character. To display an arrow sign, the bitmap values are mapped to a base address location, say 64 (ASCII code 0). The symbol locations with their base addresses are given below:

ASCII Code 0 1 2 3 4 5 6 7

Base Address 64 72 80 88 96 104 112 120

This is achieved by first sending the address location (64) to LCD command register. Next, the bitmap values (0, 4, 2, 31, 2, 4, 0, 0) are sent to the LCD data register. Now the arrow sign gets stored at the first address. Now whenever this symbol is to be displayed, its location needs to be sent to the command register of LCD.

The concept here lies in the fact one can write to the CG RAM. When an LCD is first powered up. When the controller receives an ASCII code in the range that's mapped to the CG RAM. Each byte of CG RAM is mapped to a five-bit horizontal row of pixels. These characters correspond to ASCII codes 0 through 7. Switch to Data Mode by changing the setting of RS pin . The steps involved are:    Set RS (Register Select) and R/W (Read/Write) pins of the LCD to initialize the LCD to accept instructions Set the CG RAM address by sending an instruction byte from 64 to 127 (locations 0-63 in CG RAM). Writing to CG RAM Writing to CG RAM is a lot like moving the cursor to a particular position on the display and displaying characters at that new location. it uses the bit patterns stored there to display a pattern on the LCD. so 64 bytes of CG RAM is enough to define eight custom characters. thereby defining one’s own graphic symbols. If necessary. CG RAM contains random garbage bits.There's a 64-byte hunk of RAM (random-access memory) that the LCD controller uses in the same way as character-generator (CG) ROM. CG RAM may be cleared by writing 00 into each CG RAM cell. and LCD characters are typically eight rows high.

j. R/W (pin5) and EN (pin6) are connected to the pins 0. 128.i++) for(j=0.  To display the defined custom character print ASCII codes 0 through 7. switch to Command Mode to set address counter to a valid display address (e. The LCD controller automatically increments CG RAM addresses. sbit rs=P3^0. //Register select pin // Read write pin //Enable pin void delay(unsigned int count) { int i. in the same way as it increments cursor positions on the display. void lcd_command(unsigned char comm) { lcd_data_pin=comm. sbit en=P3^6. To leave CG RAM. P3^1 & P3^6. Now bytes are once again being written to the visible portion of the display. 1 and 6 of port P3 of the controller (P3^0.  Send bytes with the bit patterns for your symbol(s). //Function to send commands to LCD.h> sfr lcd_data_pin=0xA0. sbit rw=P3^1. //Program to create and display custom characters note symbol smilies. output of microcontroller AT89C51 (from port P2) goes to data pins of LCD numbered 7-14. respectively).j++). or the home instruction (byte 2). In the circuit.i<count. The control pins RS (pin4). musical #include<reg51.g.j<1275. . for(i=0. 1st character of 1st line). } // Function to provide time delay in msec. the clear-screen instruction (byte 1). heart.

en=0. delay(1). } //Function to send data to LCD void lcd_ini() { //Function to initialize the LCD lcd_command(0x38). en=1. delay(2). } //Set cursor to blink at line 1 positon 2 . en=0. rw=0. } void lcd_data(unsigned char disp) { lcd_data_pin=disp.en=1. rs=0. lcd_command(0x82). lcd_command(0x0F). delay(1). rs=1. delay(2). rw=0. delay(2).

lcd_data(4). lcd_data(4). delay(10). lcd_data(0). lcd_data(10). . lcd_data(17). //Address of the location where the character is to be //Address where values of the first custom character is // Displaying the character created at address 0x64 lcd_command(72). lcd_data(17). lcd_data(21).void character() { lcd_command(64). lcd_data(14). lcd_data(10). lcd_data(0). lcd_data(0). lcd_data(0). lcd_data(0). lcd_command(0x80). displayed lcd_data(0). lcd_data(10). stored lcd_data(0). lcd_data(1). lcd_command(0xC0). lcd_data(0).

lcd_data(5). lcd_data(0). lcd_data(14). delay(10). lcd_data(3). lcd_data(1).delay(10). lcd_command(0x84). lcd_data(27). lcd_data(2). lcd_data(3). . lcd_command(0x82). lcd_command(80). lcd_data(0). lcd_data(24). lcd_command(88). lcd_data(0). lcd_data(11). lcd_data(9). delay(10). lcd_data(17). lcd_data(9). lcd_data(10). lcd_data(4). lcd_data(0).

lcd_data(0). lcd_data(31). lcd_command(104). lcd_data(5). lcd_data(17). lcd_data(0). lcd_data(17). delay(10). lcd_data(14). lcd_data(14). lcd_data(17). lcd_command(0x86). lcd_data(10). lcd_data(0). lcd_data(0). delay(10). lcd_data(10). lcd_data(0). lcd_data(4). lcd_command(112). lcd_data(14). lcd_data(4). . lcd_data(0).lcd_command(96). lcd_command(0xC2).

lcd_data(0). delay(10). lcd_data(0).lcd_data(0). lcd_data(17). lcd_data(7). lcd_data(14). lcd_data(6). lcd_data(10). lcd_data(4). lcd_data(10). lcd_command(0xC6). lcd_data(0). lcd_data(17). } void main() . delay(10). lcd_data(0). lcd_data(4). lcd_command(0xC4). lcd_command(120). lcd_data(0). lcd_data(17). lcd_data(0). lcd_data(31).

character(). } .{ lcd_ini().