Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

How to interface LCD with PIC18F4550 Microcontroller


Developed By: 
Amit Joshi

The character LCDs are the most commonly used display modules. These LCDs are used to display text using alphanumeric and special characters of font 5x7/5x10. For basic working and operations of a character LCD, refer LCD interfacing with 8051. Here PIC18F4550 has been used to display a single character on a 16x2 character LCD.


For basic details and operations of character LCD, refer LCD interfacing with 8051. Here LCD has been interfaced in 8-bit mode* with data pins (D0-D7) connected to PortB of PIC18F4550. The LCD control pins RS, R/W and EN are connected to PortA pins RA0, RA1 and RA2 respectively.

*Character LCD can also be interfaced by using only 4 data lines. Refer LCD interfacing in 4-bit mode.
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


Circuit Diagram



This Code is only visible to Registered users. Please Login/Register



Presets | Variable Resistors
A preset is a three legged electronic component which can be made to offer varying resistance in a circuit. The resistance is varied by adjusting the rotary control over it. The adjustment can be done by using a small screw driver or...
16 x 2 LCD | 16x2 Character LCD Module


LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments...

PIC18F4550 Microcontroller Image

PIC18F4550 is an 8-bit microcontroller of PIC18 family. PIC18F family is based on 16-bit instruction set architecture. PIC18F4550 consists of 32 KB flash memory, 2 KB SRAM...

Browse 4m+ Electronic Products

Pick the right product for your next design project with "Mouser Store". Mouser Electronics brings broadest range of semiconductors and electronic components from over 500 industry leading suppliers. 
Mouser specializes in the rapid introduction of new products and technologies for design engineers and buyers that includes semiconductors, interconnects, passives, and electro-mechanical components. Providing the best possible service with the flexibility of not requiring a minimum order and same-day shipping, Mouser has it all.
When you need the right part right now, think of Mouser
Thank you
Team EG


You are here