PIC16F84A LCD interfacing code (using 3 pins only) + Proteus simulation

This post provides the LCD[1] interfacing code using only 3 pins of PIC16F84A microcontroller. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

PIC16F84A LCD interfacing

It is assumed that you know how to make an LED blink with PIC16F84A microcontroller. If you don’t then please read this page first, before proceeding with this article.

PIC16F84A microcontroller has 13 IO pins. A 4×4 keypad needs 8 pins to interface with controllers. LCD needs at least 6 pins to interface with controllers. In order to interface keypad and LCD, both with PIC16F84A we need at least 14 pins. So it is not possible to directly attach LCD and keypad both with PIC16F84A even in 4bit mode[2]. To make this possible, a serial to parallel shift register IC (4094) is used in this circuit. In this way by only using 3 pins of PIC16F84A microcontroller, we can interface LCD with it in 4bit mode. This is shown below in the figure.

In the above figure, RA0 pin is being used as Enable pin for LCD. RA1 pin is used as Clock pin and RA2 pin is used as Data pin for 4094 IC. When code starts running, then Hello is displayed on the LCD screen as shown in the above figure.

PIC16F84A LCD interfacing schematic


In the code you can easily select pins to be used for interfacing with the LCD. Following figure shows the pin selection code.

Here for example, you can change RA0 to RA3 if you want to attach Enable pin of the LCD on pin2 of PIC16F84A. You will also need to change LCD_E_Dir to TRISA3 for RA3.

The code for the main function is shown below.


LCD interfacing code using 3 pins for PIC16F84A was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.


For more detail: PIC16F84A LCD interfacing code (using 3 pins only) + Proteus simulation

Current Project / Post can also be found using:

  • pic16f877a code for lcd

Leave a Comment

= 4 + 4

Read previous post:
LED car headlight design can benefit from thermal simulation, says Mentor

The exterior conceals new technology behind the bezels that make possible such features as adaptive beams and LED matrix beams,...

Scroll to top