The 16x2 character LCD can also be used to display custom characters other than numerals, alphabets & special characters. Some special shapes like hearts, arrows, smileys etc. can easily be displayed on the 5x7 and 5x10 pixel pattern of character LCD.

Several automated and semi-automated devices require a message to be displayed in order to indicate their working status.The 16x2 character LCD can also be used to display custom characters other than numerals, alphabets & special characters. Some special shapes like hearts, arrows, smileys etc. can easily be displayed on the 5x7 and 5x10 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. LCDs are easy to program and prove to be a better display unit as compared to other devices like seven-segments and LED display units. The reasons being: LCDs are economical, easily programmable. LCD can be easily interfaced with a microcontroller PIC18F4550 to display a message or status of a device.


Liquid Crystal Display also called as LCD is very helpful in providing user interface PIC18F4550 as well as for debugging purpose. A liquid crystal display (LCD) is a flat panel display that uses the light modulating properties of liquid crystals (LCs). LCD Modules can present textual information to user.

A 16×2 LCD module type of 16 rows and 2 columns of 5×7 or 5×8 LCD dot matrices. It is available in a 16 pin package with back light, contrast adjustment function and each dot matrix has 5×8 dot resolution .VEE pin is meant for adjusting the contrast of the LCD display and the contrast can be adjusted by varying the voltage at this pin.

The 16×2 has two built in registers namely data register and command register. Data register is used for placing the data to be displayed, and the command register is used to place the commands. The 16×2 LCD module has a set of commands each meant for doing a particular job with the display. High logic at the RS pin will select the data register and Low logic at the RS pin will select the command register, the pin diagram is shown in figure 6. If we make the RS pin high and the put a data in the 8 bit data line (DB0 to DB7), the LCD module will recognize it as a data to be displayed. If we make RS pin low and put a data on the data line, the module will recognize it as a command

Pin configuration:


While VCC and VSS provide +5V and ground respectively, VEE is used for controlling LCD contrast.


There are two important registers inside the LCD. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data that is sent is a text data which should be displayed on the screen.

To display letters and numbers, we send ASCII codes for the letters A-Z, a-z and numbers 0-9 to these pins while making RS=1. There are also instruction command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor. We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive the information.


The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands, so RW will almost be low.


The EN line is called "Enable". This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should first set this line high (1) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN low (0) again. The 1-0 transition tells the 44780 to take the data currently found on the other control lines and on the data bus and to treat it as a command.


LCD can be interfaced with microcontroller in 4 Bit or 8 Bit mode. It differs in how data is send to LCD. In 8 bit mode to write a character, 8 bit ASCII data is send through the data lines D0 – D7 and data strobe is given through E of the LCD. LCD commands which are also 8 bit are written to LCD in similar way.

But 4 Bit Mode uses only 4 data lines D4 – D7. In this mode 8 bit character ASCII data and command data are divided into two parts and send sequentially through data lines. The idea of 4 bit communication is used save pins of microcontroller. 4 bit communication is a bit slower than 8 bit communication but this speed difference can be neglected since LCDs are slow speed devices. Thus 4 bit mode data transfer is most commonly used.


CG ROM : this the memory which holds the permanent fonts you call to be displayed . this holds the pattern for every single character of predefined lcd font. and you call the content of this memory by the placeing corresponding ascii value on the lcd port . like for retrieval of 'A' you have to send the ascii value of 'A' which is 0x41 to the lcd. CGROM can also be seen as computer hard drive from where you load your required program into ram to start working. but it is not modify able because it's rom.

DD RAM : DDRAM is the memory which holds only those characters which are currently on the screen . means if there is a message is currently being displayed on the screen then it has to be on the DDRAM for example if you want to display "hello" on the screen then you have load pattern of h from the CG ROM TO DD RAM then do the same for 'e' ,'l' ,'l' and 'o'. the address of cg ram is totally depends on the size of the lcd like for

16 x 2 LCD

Row1 0x80 0x81 0x82 0x83 0x84 0x85 0x86 through 0x8F

Row2 0xCO 0xC1 0xC2 0xC3 0xC4 0xC5 0xC6 through 0xCF

20 x 1 LCD

Row1 0x80 0x81 0x82 0x83 through 0x93

20 x 2 LCD

Row1 0x80 0x81 0x82 0x83 through 0x93

Row2 0xCO 0xC1 0xC2 0xC3 through 0xD3

20 x 4 LCD

Row1 0x80 0x81 0x82 0x83 through 0x93

Row2 0xCO 0xC1 0xC2 0xC3 through 0xD3

Row3 0x94 0x95 0x96 0x97 through 0xA7

Row4 0xD4 0xD5 0xD6 0xD7 through 0xE7

40 x 2 L CD

Row1 0x80 0x81 0x82 0x83 through 0xA7

Row2 0xCO 0xC1 0xC2 0xC3 through 0xE7

There are three memories in LCD to manipulate display characters:

1. CGROM – character generating ROM which is responsible for stored standard character pattern.

2. CGRAM – character generating RAM which holds custom character pattern space ( total 8 in 2×16 module).

3. DDRAM – data display RAM which stores ASCII codes.

Steps to understand how character display:

1. Control unit of LCD receives signal(basically it is ASCII code) from user and ask to DDRAM for its match.

2. If ASCII code match, control unit maps corresponding character pattern from CGROM.

3. According to that character pattern, LCD screen energies and we can see character on it .

In the 4-bit mode the (8-bit) data/command is sent in nibble (four bits) format to LCD. The higher nibble is sent first followed by the lower nibble. LCD is configured for 4-bit mode by sending appropriate instruction known as Function Set. The Function Set is hexadecimal instruction for LCD MPU unit which selects the working modes of LCD. The Function Set is given below along with its description.


DL - Data Length

N - No. of Lines

F- Font


Programming Steps:

Before displaying anything on LCD, it needs to be configured with proper instructions. The following programming steps explain the procedure of configuring the LCD and display a character on it.

Step 1: Initialize the LCD.

• The LCD must be initialized the by following pre-defined commands of character LCD.

• 0x38, to configure the LCD for 2-line, 5x7 font and 8-bit operation mode

• 0x0C, for Display On and Cursor Off

• 0x01, to Clear Display screen

• 0x06, to increment cursor

• 0x80, to set cursor position at first block of the first line of LCD.

The above set of commands is written in lcd_ini() function of the adjoining code.

Step 2: Send the commands to LCD.

• Send the command byte to the port connected to LCD data pins

• RS=0, to select command register of LCD

• RW=0, to set the LCD in writing mode

• EN=1, a high to low pulse to latch command instruction

• Delay of 1ms

• EN=0

The above set of commands is written in lcdcmd(unsigned char) function.

Step 3: Send data to LCD.

• Send data at the port which connected to LCD data pins

• RS=1, register select to select data register of LCD

• RW=0, this set the LCD in writing mode

• EN=1, a high to low pulse to latch data

• Delay of 1ms

• EN=0

The lcddata(unsigned char) function has the above set of instructions.

Step 4: Display character on LCD.

The functions lcdcmd() and lcddata() are user-defined functions. They are used to send a character (E in this case) to be displayed on LCD

lcdcmd(0x38); // send command 0x38 to LCD

lcddata(‘E’); // send character E to LCD


• Professional-looking text and tone output on any microcontroller application

• Easy serial debugging without a PC

• Real-time sensor data output on autonomous robot

Proteus design for LCD interfacing with PIC

Orcad design for LCD interfacing with PIC

LCD interfacing with PIC

/*  Name     : main.c
 *  Purpose  : Source code for BUZZER Interfacing with PIC18F4550.
 *  Author   : Gemicates
 *  Date     : 2017-06-12
 *  Website  :
 *  Revision : None
#include <htc.h>                            // Header file for PIC18F4550  
#define _XTAL_FREQ 12000000                 // 12MHZ

#define input PORTD                         // PORTD as input       
#define Buzzer PORTCbits.RC0                // To set a single pin(RC0) as output

                                            // __CONFIG(PLLDIV = 5,CPUDIV = OSC1 / 2,USBDIV = 2,FOSC = HIGH_SPEED HS);
#pragma config WDT = OFF

void delay(int msec)		            // delay function   
	int i,j;


void main()									
		TRISD = 0xff;               // PORTD as output
		TRISC = 0Xfe;               // Upper bits as input and Lower bits as output.										
		switch(input)	            // Switch statement
			case 0xFF:                      
				Buzzer = 0; // Buzzer ON condition
			case 0xFD:
				Buzzer = 1; // Buzzer OFF condition
				            // delay(100);
				            // Buzzer = 1;

Error message here!

Show Error message here!

Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!

Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!

Back to log-in