LCD Module Interface with PIC16F877A

This article describe the hardware setup required for interfacing HD44780 based alphanumeric LCD modules with a PIC16F877A microcontroller. The software part consisting of the LCD library for PIC, its setup and use with MPLAB X IDE and XC8 compiler are described in a separate article.

A common controller chip used in many alphanumeric LCD module is the HD44780. The purpose of the controller is to generate pixel patterns and drive individual pixels of the LCD to show characters and symbols. In this method the main microcontroller running your application code does NOT need to generate the pixel patterns, it just need to tell the controller chip which character or symbol to show the rest is done by the controller, i.e. the HD44780.

The same controller chip is used in many differently sized alphanumeric LCDs. Thus the connection schematic and driving code is same.

Pin Details of LCD Module

All HD44780 based LCD modules have 16 pin connecters. The detail about these pins is given below.

16x2 alphanumeric lcd module hd44780 controller pin diagram

Interface pins of LCD Module


Pin Number

Pin Name

Pin Type Connected with PIC16F877A’s pin
1 VSS Power Supply
2 VCC Power Supply
3 VEE Contrast Adjust
4 RS Control Line RD4
5 R/W Control Line RD5
6 E Control Line RD6
7 DB0 Data Line
8 DB1 Data Line
9 DB2 Data Line
10 DB3 Data Line
11 DB4 Data Line RD0
12 DB5 Data Line RD1
13 DB6 Data Line RD2
14 DB7 Data Line RD3
15 LED+ Backlight Power
16 LED- Backlight Power

Common modules works with 5v supply. Pin 1 is connected to GND and pin 2 is connected to +5v supply. The pin 3 is the contrast adjust pin and proper wiring of this pin is very important to get anything visible on the screen. Even if you have done everything perfectly, but an improper wiring of this line can lead to a complete blank display !

A 10K preset is used as a voltage divider to get any voltage between 0v and 5v. This voltage is feed to the VEE pin. So after everything is ready and you have programmed your PIC Micro to show something on the LCD, you have to adjust this preset before you can see anything on the LCD.

Then their are three control line, namely the RS, R/W, E. these are connected to microcontrollers general purpose input output line.

After that comes the data lines DB0 to DB7 (8 bit wide). These are also connected to microcontrollers general purpose input output line. The HD44780 controller also has a 4 bit data transfer mode. This mode is very useful as it uses only 4 bit lines to transfer the whole 8 bit data. The data is transferred in two transfers each of 4 bit. Thus this technique requires only four i/o line of microcontroller in place of eight. This smart saving of i/o lines is very useful as you are free to use the saved i/o lines for other purpose in your design.

In four bit transfer mode, data bits DB0-DB3 are left unconnected only DB4 to DB7 are connected with microcontroller.

Finally comes the backlight power lines. As you may be knowing the backlight helps viewing the contents of the LCD module in dark situations. Making the backlight lit is simple, as it is just a set of LEDs. You need to supply +5v and a GND connection to make it glow. But as with any LED it is suggested to use a current limiting resistor in series with the backlight. The resistor we prefer is a 100ohm resistor (a 1/4th watt resistor is enough but you may use 1/2 watt also).

Complete schematic of the LCD subsystem is shown below.

alphanumeric lcd hd44780 subsystem

LCD Module Subsystem

16×2 LCD Board

The 16×2 LCD Board makes it easy to interface a 16×2 LCD module with low cost microcontroller development board which do not have built in support for lcd modules. This board has the following

  • 16×2 lcd module (you can choose either a green or a blue backlight lcd)
  • The contrast adjust resistor.
  • Backlight current limiting resister.

so you can see that it has all the things required by the lcd subsystem in a nice pcb.

In addition to the above, it also has the ability to turn on or off the lcd backlight and also control its brightness using pwm technique.

16x2 lcd board description

LCD Board Description


lcd board adjust contrast

Adjusting Contrast


lcd back light control jumper

Backlight Control Jumper

Connecting with PIC16F877A Development Board

The PIC16F877A development board as the PIC16F877A microcontroller chip and its supporting basic circuitry all in a nice high quality PCB. The development board comes fully assembled and tested, thus makes it ideal for doing experiments for learning by beginners.

40 pin pic development board

40 PIN PIC Development Board

In the bottom portion of the pic development board you can see a row of male headers. Most of these pins are the microcontrollers general purpose input/output lines and the rest are 5v and GND supply lines. Using these pins you can connect external peripherals (like the LCD board or something else) to do your experiment. The pins are clearly labeled on the PCB surface.

Since other peripheral boards also have male headers for interconnection, you need a female to female burg wires like these to make connections.

burg wires female to female

Burg Wires


pic development board and lcd board

LCD Board Connection

Connect LCD Board with the development board using the above mentioned burg wires according to the table given below.

LCD Board

40 PIN PIC Dev Board

1 R/W RD5
2 RS RD4
3 LED PWM Not Connected
4 VCC 5v
6 DB7 RD3
7 DB6 RD2
8 DB5 RD1
9 DB4 RD0
10 E RD6

5v and GND connection points are labeled in the development board as Extra 5v OUT. Please refer to the image below for their positions. 5v and GND are also available in the 40 pin row of male headers. In the image below Yellow wire is 5v and Green wire is GND.

5v and GND connection on dev board

Close up of Connection.

Schematic of the whole setup

schematic of pic16f877a interfaced with LCD module

PIC16F877A Interfaced with LCD Module Schematic (Click to Enlarge …)

Next Part

  • LCD Library for PIC – Setup on MPLAB X IDE This article describes the setup and use of the C library for hd44780 based alphanumeric lcd modules. Here we describe how to setup a MPLAB X project with support for lcd related functions. The library is designed for compilation and use with Microchip’s XC8 C Compiler.

By Avinash Gupta

JLCPCB Prototype: $2 for 10 pcs PCBs, 48 Hours Quick Turn

China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day

Get quote online easily: quote

Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.


Avinash Gupta is solely focused on free and high quality tutorial to make learning embedded system fun !

More Posts - Website

Follow Me:
FacebookLinkedInGoogle Plus

Line Following Robot Kit

15 thoughts on “LCD Module Interface with PIC16F877A

  • By Uttam Dutta - Reply

    Mr. Avinash,
    Thank You so much, a new article after long long time, We want to see this site alive and vibrant.
    Expecting also PIC KIT 2 or 3 from you

    • By Avinash - Reply

      Ok Dada you are most welcome.

  • Pingback: Setup and Use of LCD Library for PIC |eXtreme Electronics

  • By David Pickering - Reply

    A big thank you
    I am new to writing programs only ever flashed chips
    Getting a bit old now but something I want to learn.

    • By Avinash - Reply

      Ok Dave you are most welcome.

  • By Goutam Das - Reply

    Hey, THANKS A BUNCH for this Great article and your effort!! Done this without any problem.…
    I am recently working on <> project. Everything goes well, but facing a problem which is getting a continuous signal from PIR SENSOR. May you please help me just telling me How to adjust the sensor to get SIGNAL only when Motion is detected!!!

    Help me bro,PLS.

  • By parbodh - Reply

    hello,thank u so much sir,i really like this artical .but,having some problum to understand about using components……please help me.about this artical for more understanding about it. i will be thankful to u for this,

  • By Shivaraja sajjan - Reply

    What happens if we left open the led+(15) n led-(16) as we use to do in simulation??

    • By Avinash - Reply

      @Shivaraja sajjan Why to you wanna increase trouble in your life?

      If the display is transmissive time, you won’t see anything !



  • By Solomon Ikem - Reply

    Hello Sir, Please am not good at writing programs and i have a project on Motor speed Monitor and control systems using a GSM modem. I dont know how to write a program for the PIC 16F877A to communicate with the GSM Modem, LCD, Optical encoder . Really thankful if u can help me here…

  • By bekele - Reply

    i am happy with u ….next to this posting pic16f877a+microc language rather than mplab is more applicable

  • By satdaveuk - Reply

    Has anyone got Lay files for the PIC16F877A Interface and LCD module or even split into 2 parts will help.

  • By Ramesh - Reply

    I sir I am not a program writer could you help me for pic 877 .purpose for using lcd meter to read input &outpui voltage.

  • By suneha tabassum - Reply

    can u please send the code???????


    Thank you so much….Its really useful

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + two =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>