Creation and display of custom characters on 16×2 LCD using 8051 microcontroller(89c51,89c52)
Roberto Magalhães
This tutorial is about how to create and display 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. Instead, they are new and designed by us. I first recommend you to follow the following simple tutorial. This will enlighten you about the internal structure of character LCD, its registers, memory and controller used to control the displayed characters (HD4478). But if you just need the project code, proceed.
How to display custom characters on the Character LCD.
How the NXN LCD works
Custom font display on 16×2 LCD with 89c51 microcontroller
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 the 16x2 character LCD and then invoked by the controller for display on the 16x2 LCD. CG supports “ Generated Character ” RAM (read-only memory). I used Hitachi 16×2 LCD in the project you can use any other. But make sure to change some initialization commands in the code if you are using lcd of any other size other than 16×2 (Read the datasheet-Commands for initialization of lcd with size other than 16×2).
Custom Characters on 16×2 LCD Circuit Diagram
The project circuit is also simple. Port 3 pins 5 and 6 are used as rs (register set) and en (enable) pins for LCD, I don't know what it is, just click on the link you will get a good tutorial about it (How to NXN LCD works). Port 1 is of 8051 microcontroller and is connected to data pins of 16×2 LCD. External 11.0592 MHz crystal is used to provide clock to microcontroller.
Custom characters displayed on 16×2 LCD with 89c51 microcontroller circuit diagram
Custom character generation with 8051 microcontroller project code
I'm using keil ide to write and compile code. In the code, first of all, I have included the predefined header file reg51.h . This library must be included whenever you are writing code for 8051 (89c51) series microcontrollers in keil ide. The absence of it may cause a problem for you, generally the compiler will not compile your file.
I have defined the required custom characters in the form of character arrays which are later used to generate characters. Port 1 of the 89c51 microcontroller is used to send data and commands to the LCD. The rest of the code is simple, the delay function is to generate some arbitrary delay. The lcdint function is initializing the lcd.In my main function I am generating custom characters and then printing them on a 16×2 LCD. The main function is in while(1) continuous cycle. Due to this while(1) continuous loop characters are continuously displayed on the 16×2 character LCD screen.
You can only create 8 characters at a time in CG-RAM. I also only made 8 custom characters, but it's a simple method to generate more. The method is to first create 8 characters and then display them on the LCD. Now again make 8 characters. The creation of new characters will replace previous CG-RAM characters. In fact, CG-RAM is overwritten by new characters. Therefore, by applying this simple technique you can create as many characters as you need.If you have any questions about the post or can't understand the code, leave your comments below.
Download the project files and code (C++,HEX). The code is written in c language. keil uvision 4 is used to generate hexadecimal code and to compile code. The download folder contains all the project files.
Custom character on LCD with 89C51 microcontroller
Ao escolher uma linguagem de programação para o desenvolvimento de aplicativos, é importante considerar as características e os recursos oferecidos por cada uma. Neste artigo, vamos comparar duas l...
Na era digital em que vivemos, a gestão eficiente de dados tornou-se fundamental para o sucesso de qualquer negócio. Empresas de todos os tamanhos e setores enfrentam o desafio de armazenar, proces...
As ligas de titânio e alumínio têm sido um dos principais domínios na ciência dos materiais devido às suas características únicas e diversidade de aplicações como um material de alta resistência. E...
As vendas de veículos automotores no Brasil continuam em alta, com um crescimento expressivo de 16,4% no acumulado de janeiro a outubro de 2024 em comparação ao mesmo período do ano anterior. Segun...
A integridade estrutural de uma junta soldada depende crucialmente da qualidade da penetração da solda. Quando a penetração é insuficiente, a resistência da união fica comprometida, podendo levar a...
Cálculo de Esforço Normal Máximo em Barras de Aço
A definição da resistência à compressão de uma barra de aço é fundamental para garantir a segurança e a estabilidade de um projeto estrutural. Par...
Cálculo de Flambagem de Compressão em Barras de Aço
A flambagem em barra de aço é um fenómeno comum em estruturas que sofrem cargas compressivas, como alas de pontes, vigas e colunas. No Brasil, é...
De acordo com o Instituto Nacional dos Distribuidores de Aço (INDA), as importações brasileiras de aço devem crescer cerca de 11% em 2025. Esse aumento é impulsionado pela competitividade do mercad...