You have no items in your shopping cart.

Subtotal: 0.00

How to Interface LCD with PIC16F877A PIC Advanced Development Board

PIC16F/18F Advanced Development Board

the is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchip’s PIC (PIC16F877A), PIC16F/18F Slicker Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.

LCD (Liquid Crystal Display)

Liquid Crystal Display also called as LCD is very helpful in providing user interface 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.

Interfacing LCD

Fig. 1 shows how to interface the LCD to microcontroller. The 2x16 character LCD interface card with supports both modes 4-bit and 8-bit interface, and also facility to adjust contrast through trim pot. In 8-bit interface 11 lines needed to create 8-bit interface; 8 data bits (D0 – D7), three control lines, address bit (RS), read/write bit (R/W) and control signal (E).

Fig. 1 Interfacing LCD to Microcontroller


Interfacing LCD with PIC16F877A

We now want to display a text in

PIC16f/18F Slicker Board

by using LCD module. In

PIC16f/18F Slicker Board

contains the LCD connections in a single header.


PIC16f/18F Slicker Board

has eleven numbers of LCD connections, connected with I/O Port lines (PORTE.0 – PORTE.3 && PORTD.0 – PORTD.7) to make LCD display.

Pin Assignment with PIC16F877A





LCD | 128x64 GLCD Selection





















*Connect PORTD with JP9 (LCD) via FRC Cable


*Place a Jumper on BL-SEL (J7) to Enable Backlight


*Press RESET Once.


*Adjust the POT (CONTRAST) Right or Left until the    

   letters are visible











Output: The Strings “PIC DEV. BOARD” and "LCD DEMO PROGRAM" will be displayed on LCD.


Circuit Diagram to Interface LCD with PIC16F877A

Source Code

The Interfacing LCD with PIC16F877A program is very simple and straight forward, which display a text in 2 X 16 LCD modules. Some delay is occurring when a single command / data is executed.

C Program to display a text in LCD using PIC16F877A

#include<pic.h> //Define PIC Registers #include<stdio.h> //Define I/O Functions __CONFIG(0x3f72); //Select HS oscillator, Enable (PWRTE,BOREN), //Disable (CPD,CP,WDTEN,In-circuit Debugger) #define RS RA1 //LCD Register Select #define RW RA2 //LCD Read/Write Pin #define EN RA3 //LCD Enable Pin #define DATA PORTD //LCD Data Port #define DATADIR TRISD //LCD Data Port Direction Register #define CNTRLDIR TRISA //RS,RW,EN Direction Register void lcdinit(void); //LCD initialization Function void lcdclr(void); //LCD Clear Function void lcdcomd(unsigned char); //LCD Command Declaring Fucntion void lcddata(unsigned char); //LCD Data Display Fucntion void DelayMs(unsigned int); void main() { int i; unsigned char First[]={" PIC DEV. BOARD "}; unsigned char Secnd[]={"LCD DEMO PROGRAM"}; DelayMs(500); lcdinit(); DelayMs(500); while(1) { lcdclr(); lcdcomd(0x80); for(i=0;i<16;i++) //Display the Message { lcddata(First[i]); DelayMs(50); } lcdcomd(0xc0); for(i=0;i<16;i++) //Display the Message { lcddata(Secnd[i]); DelayMs(50); } DelayMs(500); } } void lcdinit(void) { int i; unsigned char command[]={0x38,0x0c,0x06,0x01}; //LCD Command set for 8 bit Interface, 2 Lines, 5x7 Dots ADCON1 = 0x07; //Make PORTE Pin as Digital CNTRLDIR = 0x00; //Make LCD control port (PORTE) as output DATADIR = 0x00; DelayMs(50); //Make LCD Data Port (PORTD) as output port for(i=0;i<4;i++) { lcdcomd(command[i]); //Send the Initialisation Commands DelayMs(5); } DelayMs(500); } void lcdclr(void) //Send LCD clear command { lcdcomd(0x01); DelayMs(2); } void lcdcomd(unsigned char cmd) { RS=0; RW=0; //Select Command Register, R/W--write enabled EN=1; //Enable LCD to accept commands DATA=cmd; EN=0; DelayMs(5); //Give a Pulse via Enable pin } void lcddata(unsigned char byte) { RS=1; RW=0; //Select Data register, R/W--write enabled EN=1; DATA=byte; //Give a Pulse via Enable pin EN=0; DelayMs(5); } void DelayMs(unsigned int Ms) { int delay_cnst; while(Ms>0) { Ms--; for(delay_cnst = 0;delay_cnst <220;delay_cnst++); } }

To compile the above C code you need the Mplab software & Hi-Tech C Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board.

The PICKIT2 software is used to download the hex file into your microcontroller through USB port.

Testing the LCD Module with PIC16F877A

Give +12V power supply to

PIC16f/18F Slicker Board

; the LCD is connected with microcontroller

PIC16f/18F Slicker Board

. When the program is downloading into PIC16F877A in Slicker Board, the screen should show the text messages.

If you are not reading any text from LCD, then you just check the jumper connections & adjust the trim pot level. Otherwise you just check it with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

General Information

    • For proper working use the components of exact values as shown in Circuit file. Use new components.
    • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
    • Use the exact value crystal shown in schematic.
    • More instructions are available in following Tutorials,


PIC Advanced Development board

Create & Debug a project in Mplab using PIC16F877A