Fads to Obsessions and Beyond...

Free domain for life, exceptional technical support, website transfer

LCD Interfaced to PIC

Interfacing of a 16x2 LCD serial module (compatible HD44780 LCD) to a PIC microcontroller is demonstrated. The PIC microcontroller is connected to PC via RS232 and received data is displayed on the LCD.

Typical microcontroller projects generally require user output. Individual LED's or similar can provide visual feedback (e.g., a particular function and or input/output is active or inactive) and seven-segment LED displays offer the ability to denote alphanumeric information (e.g., digits for a numerical display). However, the now ubiquitous Hitachi HD44780 LCD controller is an alphanumeric dot matrix liquid crystal display (LCD) controller that enables easy display of multi-line text (typical formats 16 chars x 2 lines, 20 chars x 2 lines).

The HD44780 LCD controller (available since 1987) is now superceded in commerical products (1), but is widely used in DIY projects due to the ease of use and now low cost. Although now even in DIY projects parts such as the Nokia 5110 84x48 LCD module are replacing the HD44780 LCD controller due to equivalent cost and more flexibility in the Nokia 5510 raster display enabling graphics and not just alphanumeric text.

A 16x2 LCD serial module (compatible HD44780 LCD) is interfaced to a PIC18F248 microcontroller and CCS C code is used to display received data from a connected PC via RS232 connection.

See the various sections below for circuit details, schematic diagrams, software/firmware and other details.

The schematic for a 16x2 LCD serial module (compatible HD44780 LCD) with connections to a PIC18F248 is given in the Schematics Section below. The ancillary circuitry for the PIC18F248 also includes connection to a PC via RS232 connection.

Power Supply

A typical "wall-wart" power-supply is used (a surplus laptop charger in this case) in conjunction with a voltage regulator (LM317T) to provide the regulated 5V required by the PIC microcontroller. This is done via the DIY PIC development board.


The Testing/Experimental Results Section details the firmware (written in CSS C code) required to display data on the 16x2 LCD serial module received from the RS232/PC connection.

Note: Image loading can be slow depending on server load.

  • LCD interfaced to PIC with RS232 SchematicLCD interfaced to PIC with RS232 Schematic

    Silver Membership registration gives access to full resolution schematic diagrams.

    LCD interfaced to PIC with RS232 Schematic

  • LCD interfaced to PIC with RS232

This project did not require a PCB.

The construction was done using a DIY PIC development board. See the photographs and schematic diagram sections.

Qty Schematic Part-Reference Value Notes/Datasheet
5R1,R4-R710K1/4W, 10% 
2R2,R34K71/4W, 10% 
1RV110K pot.potentiometer
Integrated Circuits
1U1PIC18F248PIC microcontroller datasheet
1U27805Linear Voltage Regulator  datasheet
2C1,C222pFceramic disk
1C30.33uFaluminium or tantalum electrolytic
1C40.1uFaluminium or tantalum electrolytic
1J1CONN-H55-pin connector for ICSP
1X110MHzCrystal Oscillator
1LCD1LCDLiquid Crystal Display
Description Downloads
LCD - Bill of Materials Text File Download

The following code snippet shows how to define the microcontroller I/O pins to be interfaced to the LCD. The include file "LCD.C" is provided with the CCS C compiler, and this file provides the actual driver code for the LCD. This demonstration code repeatly places the letters of the alphabet on the LCD to show the functionality.

Functions provided by the "LCD.C" driver file include lcd_gotoxy(line,column) [which enables setting the "cursor" position on the LCD], and lcd_putc(char) which is the function called to send a character (ASCII code) to the LCD.

#include <LCD.C>
#zero_ram //all variables automatically initialised to 0

#define LCD_RS_PIN     PIN_B1    
#define LCD_RW_PIN     PIN_B2      
#define LCD_DATA4      PIN_B4
#define LCD_DATA5      PIN_B5
#define LCD_DATA6      PIN_B6
#define LCD_DATA7      PIN_B7

void main() {
   int theChar;

   lcd_putc("Hello World");

   thechar = 65;   //displays chars A to Z in the 1st position on the 2nd line
   do {
      delay_ms(500);   //allow some time between updating the LCD so can see the characters
      if (thechar>90) thechar=65;

   } while (TRUE);

The Schematic Diagram Section contains schematics for connecting a 16x2 LCD serial module (compatible HD44780 LCD) to a PIC microcontoller.

The incorporation of a LCD as output device interfaced to PIC microcontroller is rather straight forward. Obviously check the polarity of Vcc and Gnd connections before powering up the unit.

The 10k potentiometer is required to adjust the contrast of the LCD screen. Upon initial power-up the LCD can appear to be not working, however, adjustment of the contrast potentiometer should enable displayed characters to be visible.

A PCF8574 port expander can be used to minimise the number of I/O pins on the microcontroller required to control the LCD. The PCF8574 provides a I2C bus.


No comments yet.

Add Comment/Question

Only Logged-In Members can add comments

"If we could sell our experiences for what they cost us, we'd all be millionaires".

Please donate any amount to help with hosting this web site.

If you subscribe (only $2/annum) you can view the site without advertisements and get emails abouts updates etc.



Only logged-in users with Silver Membership and above can download.

Silver Membership is only $2, so join now!