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

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.