Animating custom made characters on a 16x2 LCD screen can be very exciting. (Also see LCD custom characters.) This topic explains the principle and operation of a displaying animation on LCD using Microcontroller AT89C51.
There’s a useful side effect to the way the LCD controller uses CG RAM. Normally, we define a pattern in CG RAM, and then print the character. But it is also possible to change the CG RAM for characters that are already on the screen, and their appearance will change (for more detail about CG RAM and LCD refer LCD custom character and LCD interfacing).
The connections in the circuit are as follow: the output of controller (from port P2) goes to data pins of LCD numbered 7-14. The control pins RS (pin4), R/W (pin5) and EN (pin6) are connected to the pins 0, 1 and 6 of port P3 (P3^0, P3^1 & P3^6, respectively).
Sample animation: A moving arrow continuously passing through hearts.
Before animation, the custom characters of heart, cutting heart, blank screen and arrow should be stored at different addresses. For more detail on creating custom characters refer LCD custom character.
In 1st step print an arrow and two hearts placed at some distance apart.
In 2nd step print blank screen, cutting heart and 2nd heart.
In 3rd step print blank screen, heart, arrow and 2nd heart.
In 4th step print blank screen, heart, blank screen, arrow and 2nd heart.
In 5th step print blank screen, heart, blank screen, blank screen and
cutting heart.
These steps can be repeated continuously to produce an animation.
Project Source Code
###
// Program to make an animation using custom characters #include<reg51.h> sfr lcd_data_pin=0xA0; sbit rs=P3^0; //Register select (RS) pin sbit rw=P3^1; // Read write (RW) pin sbit en=P3^6; //Enable (EN) pin void delay(unsigned int count) // Function to provide time delay in msec. { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } void lcd_command(unsigned char comm) //Function to send command to LCD. { lcd_data_pin=comm; en=1; rs=0; rw=0; delay(1); en=0; } void lcd_data(unsigned char disp) //Function to send data to LCD. { lcd_data_pin=disp; en=1; rs=1; rw=0; delay(1); en=0; } void lcd_ini() //Function to initialize the LCD { lcd_command(0x38); delay(200); lcd_command(0x0F); delay(200); } void character() { while(1) { char k,position; k=0; position=0x7F; lcd_command(64); //Address where character heart is to be stored lcd_data(0); lcd_data(10); lcd_data(21); lcd_data(17); lcd_data(10); lcd_data(4); lcd_data(0); lcd_data(0); lcd_command(0x81); lcd_data(0); delay(5); lcd_command(64); lcd_command(0x84); lcd_data(0); delay(5); lcd_command(80); //Address where character arrow is stored lcd_data(0); lcd_data(4); lcd_data(2); lcd_data(31); lcd_data(2); lcd_data(4); lcd_data(0); lcd_data(0); lcd_command(0x80); lcd_data(2); delay(5); lcd_command(72); // Address where blank character is to be stored lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); lcd_command(0x80); lcd_data(1); delay(5); lcd_command(88); // Address where Arrow heart character is to be stored lcd_data(0); lcd_data(10); lcd_data(21); lcd_data(31); lcd_data(10); lcd_data(4); lcd_data(0); lcd_data(0); lcd_command(0x81); lcd_data(3); delay(5); lcd_command(72); lcd_command(80); lcd_data(1); delay(5); lcd_command(64); lcd_command(0x81); lcd_data(0); delay(5); lcd_command(80); lcd_command(0x82); lcd_data(2); delay(5); lcd_command(72); lcd_command(0x80); lcd_data(1); delay(5); lcd_command(64); lcd_command(0x81); lcd_data(0); delay(5); lcd_command(72); lcd_command(0x82); lcd_data(1); delay(5); lcd_command(80); lcd_command(0x83); lcd_data(2); delay(5); lcd_command(72); lcd_command(0x80); lcd_data(1); delay(5); lcd_command(64); lcd_command(0x81); lcd_data(0); delay(5); lcd_command(72); lcd_command(0x82); lcd_data(1); delay(5); lcd_command(72); lcd_command(0x83); lcd_data(1); delay(5); lcd_command(64); lcd_command(0x84); lcd_data(0); delay(5); lcd_command(72); lcd_command(0x80); lcd_data(1); delay(5); lcd_command(64); lcd_command(0x81); lcd_data(0); delay(5); lcd_command(72); lcd_command(0x82); lcd_data(1); delay(5); lcd_command(72); lcd_command(0x83); lcd_data(1); delay(5); lcd_command(88); lcd_command(0x84); lcd_data(3); delay(5); } } void main() { lcd_ini(); character(); } ###
Circuit Diagrams
Circuit-Diagram-of-Displaying-Custom-Animations-On-16×2-LCD-Using-8051-Microcontroller-AT89C51-On-Breadboard |
Project Components
Project Video
Filed Under: 8051 Microcontroller
Filed Under: 8051 Microcontroller
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.