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

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


This article explains how to interface an LCD with a PIC16F84A microcontroller using only 3 pins by employing a 4094 serial-to-parallel shift register. Normally, interfacing both a 4x4 keypad and LCD requires more pins than the PIC16F84A has, but using the 4094 chip reduces pin usage. The code is written in C using MPLAB with the HI-TECH C compiler, and it can be customized to use different microcontroller pins for the LCD enable signal. The setup displays "Hello" on the LCD screen, with code and simulation files available for download.

Parts used in the PIC16F84A LCD Interfacing with 3 Pins:

  • PIC16F84A Microcontroller
  • 16x2 LCD Display (4-bit mode)
  • 4094 Serial to Parallel Shift Register IC
  • Connecting wires
  • Power supply

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

Code

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.

Downloads

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


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.