This tutorial is about making and displaying custom characters on 16×2 lcd using 8051(89c51,89c52) microcontroller. By custom i mean characters that are not alphabets, digits or ASCII value characters. Rather they are new and designed by us. I first recommend you to please go through the following simple tutorial. This will clear you about the internal structure of character lcd’s its registers, memory and controller used for controlling the displayed characters (HD4478). But if you only require project code than proceed further.
After reading the tutorial you will be able to understand the tutorial/project code written below and you will also be familiar with the character generated(CG-RAM) RAM of 16×2 lcd. Custom characters are made in the CG-RAM of 16×2 character lcd and then invoked by controller for displaying on the 16×2 lcd. CG stands for “Character Generated” RAM (Read only memory). I used Hitachi 16×2 lcd in the project you can use any other. But be sure to change few initializing commands of the code if you are using lcd of any other size other than 16×2 (Read the datasheet-Commands for initializing of lcd with size other than 16×2).
Custom characters on 16×2 lcd Circuit diagram
Circuit of the project is also simple. Port-3 pins 5 and 6 are used as rs(register set) and en(enable) pins for lcd don’t know what is it just click the link you will have a good tutorial on it (How NXN lcd works). Port-1 is of 8051 microcontroller is connected to data pins of 16×2 lcd. 11.0592Mhz external crystal is used to supply clock to the microcontroller.
Custom character generation with 8051 microcontroller project code
I am using keil ide for writing and compiling code. In the code first of all I included the predefined header file reg51.h .This library is necessary to be included when ever you are writing code for 8051(89c51) series microcontrollers in keil ide. Absence of it can cause a problem for you most commonly the compiler will not compile your file.
I defined the required Custom characters in the form of Character arrays which are used later for generating characters. Port-1 of 89c51 microcontroller is used to send data and commands to lcd. The rest of the code is simple the delay function is their for generating some arbitrary delay. The lcdint() function is initializing the lcd. In my main function i am generating the custom characters and then printing them on 16×2 lcd. The main function is in while(1) continuous loop. Due to this while(1) continuous loop characters are continuously displaying on the character 16×2 lcd screen.
I defined the required Custom characters in the form of Character arrays which are used later for generating characters. Port-1 of 89c51 microcontroller is used to send data and commands to lcd. The rest of the code is simple the delay function is their for generating some arbitrary delay. The lcdint() function is initializing the lcd. In my main function i am generating the custom characters and then printing them on 16×2 lcd. The main function is in while(1) continuous loop. Due to this while(1) continuous loop characters are continuously displaying on the character 16×2 lcd screen.
At a time you can make only 8 characters in CG-RAM. I also made only 8 custom characters but their is a simple method to generate more. The method is first create 8 characters and then display them on lcd. Now again make 8 characters. Making new characters will replace the previous from CG-RAM. Actually the CG-RAM is overwritten by new characters, So by applying this simple technique you can make as many characters as you need. If you have any questions regarding the post or you are unable to understand the code please leave your comments below.
Download the project files and code(C++,HEX). Code is written in c language. keil uvision 4 is used for generating hex code and for compiling code. The download folder contains all the project files.
You may also like:
What are the top development boards for AI and ML?
What are top applications of CAN protocol?
What drone parts you need to build a quadcopter?
What are the battery-selection criteria for low-power design?
What’s a protective relay and what does it protect?
What is an Actuator Sensor Interface (AS-i)?
Filed Under: 8051 Microcontroller, Electronic Projects, Featured Contributions, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.