Projects   /   LCD & Display Projects   /   PIC16F877A

How to display custom characters on LCD using PIC16F877

Unleash creativity: Display custom characters on LCD using PIC16F877 with this Arduino project for personalized visual experiences.

Published
Updated

At a glance

CategoryLCD & Display Projects
PIC modelPIC16F877A
IncludesCircuit diagram · Proteus · Download files
Reading time~4 min
Jump to a section
  1. How to generate custom character ?
  2. Code
  3. Downloads
  4. Quick Solutions to Questions related to Custom Character Display on LCD:
  5. Related projects

Summary of How to display custom characters on LCD using PIC16F877

This article details creating custom characters on HD44780-based LCDs using a PIC16F877 microcontroller. It explains utilizing CGRAM to define 5x8 or 5x10 character patterns by calculating byte values for dot matrices. The process involves defining arrays of these values and transmitting them to the LCD controller via specific code functions, demonstrated through Proteus simulation and MPLAB compilation.

Parts used in the Custom Character Display on LCD:

  • PIC16F877 microcontroller
  • 16x2 LCD with HD44780U controller
  • 20 MHz crystal oscillator
  • MPLAB v8.85 IDE
  • HI-TECH C v9.83 compiler
  • Proteus v7.10 simulation software

This post explains the idea of creating custom characters on any LCD ( e-g on 16x2 LCD ) which has HD44780U controller in it. Almost all 16x2 or 20x2 LCDs have HD44780U controller in them[1]. This controller provides the functionality of CGRAM ( Character Generator RAM ). We can write character patterns on this RAM and then they can be easily displayed on the LCD. The code for custom character generation using PIC16F877 microcontroller and Proteus simulation can be downloaded from the 'Downloads' section at the bottom of this page.

display custom characters on LCD using PIC16F877

If you don't know how to interface LCD with PIC16F877 in 8bit mode, then you should read this post first. The required circuit for displaying custom characters on LCD is shown below.

PORTB is being used as data bus for the LCD. Also, RD1 pin is used as RS (Register Select for LCD) and RD0 pin is used as E (Enable pin for LCD).

A crystal of 20 MHz is used here. You can use any crystal value from 0 to 20MHz in this circuit. Close-up picture of the LCD is shown below.

How to generate custom character ?

I am going to explain custom character generation using an example. In the figure 2, first character displayed on the LCD is named 'Curvy Object' in the code. To generate this character, First make a box of 8 by 5 dots. Then fill the dots required to make the custom character you want to display. Following figure explains this concept.

After filling the dots, find out the value of each line. For example, ( in the figure 3 for 'Curvy Object' creation ) first line has a value of 0x01, because only first dot ( at 20 position ) needs to be displayed. Then second line has a value of 0x02, because only one dot at 21 position needs to be displayed. Similarly, third line has a value of 0x04, fourth line has a value of 0x08 and fifth line has a value of 0x10. Sixth line has the two dots to be displayed, hence 0x10 + 0x01 = 0x11 is it's value. Seventh line has all the dots to be displayed, which corresponds to a value of 0x10 + 0x08 + 0x04 + 0x02 + 0x01 = 0x1F. Eight line has no dots to be displayed, so it has a value of zero. After finding out these values make an array of these values as shown in the figure 3. This array named 'CurvyObject', which has 8 bytes of data will be transmitted to the CGRAM of LCD.

display custom characters on LCD using PIC16F877 schematic

We can program 8 custom characters when we are using 5x8 font in the LCD settings. And we can program 4 custom characters when we are using 5x10 font in the LCD settings. I have used 5x8 font in the code, hence at most 8 custom characters can be programmed. Using the approach to make the custom character described above, 2 custom characters were defined in the code. These custom character arrays are shown below[2].

Code

The code for the InitLCD() function is shown below[3]. This function is used to initialize the LCD properly with the custom characters.

Downloads

Custom character display on LCD code for PIC16F877 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: How to display custom characters on LCD using PIC16F877

  • Which LCD controller allows custom character generation?
    The HD44780U controller provides the functionality of CGRAM for writing character patterns.
  • How many custom characters can be programmed with a 5x8 font?
    You can program 8 custom characters when using a 5x8 font setting.
  • What happens if a 5x10 font is selected instead?
    Only 4 custom characters can be programmed when using a 5x10 font setting.
  • Which pins are used for RS and Enable on the microcontroller?
    RD1 is used as RS and RD0 is used as the Enable pin for the LCD.
  • Can I use a crystal frequency lower than 20 MHz?
    Yes, you can use any crystal value from 0 to 20 MHz in this circuit.
  • How is the data for a custom character line calculated?
    The value is determined by summing the binary positions of the dots required for that line.
  • What tools were used to compile and simulate the code?
    The code was compiled in MPLAB v8.85 and simulated in Proteus v7.10.
Beginner Tutorials · PIC16F877A

PIC16F877 Driving LCD in 4-Bit Mode using PIC16F877 with Proteus Simulation

Introduction This microcontroller project shows how a PIC16F877 can drive an LCD display using 4-bit mode inside a Proteus simulation.The project demonstrates...

Programmers & ICSP · PIC16F877A

EPE PIC/LCD Demo using PIC16F877 with Proteus Simulation

IntroductionThe EPE PIC/LCD Demo is a classic microcontroller project that demonstrates how a PIC16F877 can fully control a PG12864F graphical LCD.Designed as...

Motors & Robotics · PIC16F877A

Efficient Sun-Following Robot: A Solar Tracker with Microcontroller Control

Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....

LCD & Display Projects

Leveraging Blockout Banners for Effective Electronics and Tech Product Displays

Blockout banners have become a popular and effective tool for displaying electronics and tech products in various settings, from trade shows and...

LCD & Display Projects · PIC18F4520

Interfacing PIC18F4520 microcontroller with an HD44780 LCD

Introduction Being able to display data from a microcontroller visually has many advantages. It allows for menus, status indicators, and instructions to...

LCD & Display Projects

Video Project Development in the Midst of an Impromptu Online Semester

Receiving robot parts in the mail was an unexpected conclusion to the Winter 2020 semester for students. However, when faced with a...

Ibrar Ayyub

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...