Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Text animation on 20×4 LCD using AT89C52 Microcontroller

By Ashutosh Bhatt

Text animation on 20×4 LCD using AT89C52 micro controller

SUMMARY

All you might have seen scrolling message display. Matrix LED based scrolling message displays are used widely in advertising, sign boards, information display at public places and many more such applications. Such displays are made up of number of LEDs. There may be single colour (mostly RED) or multi colour LEDs and there are very nice text animation effects like appearing-disappearing text, left-right scrolling, top-bottom scrolling etc. But have you seen such animation effects on text LCD? 
 
It is possible to give such text animation effects on LCD also. In many devices it is required to display different messages or information turn by turn on LCD. If the information can not be accommodated in display area then the information is broken into pages and then pages are displayed one after another. For example the house hold energy meters displays current, voltage, power consumption, number of units consumed etc all the information turn by turn on 16×2 LCD. So in such cases it is quite better if information is displayed with animation. 
 
The given project demonstrates how to generate different text animation effects like scroll message left, right, top or bottom or appear / disappear text slow / fast. The project uses micro controller AT89C52 to display message and generate various animation effects on LCD and it uses 20×4 Text (alphanumeric) LCD for display. So it is very nice, interesting and use full projects and let us see how it is done. Here is the circuit diagram followed by its description and operation. Afterwards, the logic for software program is explained in detail.    
 
DESCRIPTION
 
• The LCD data bus is connected with port P2. Control pins RS and En are connected with port P3 pins P3.0 and P3.1 respectively. RW pin is connected to ground to enable LCD write always enable.
 
• 1K Pot is connected to VEE pin to vary brightness of LCD.
 
• One button is connected pin P3.2 as shown that generates external interrupt when pressed.
 
• One capacitor is connected between Vcc and Reset input pin that provides power on reset. Push button is connected across this capacitor that gives manual reset when pressed.
 
• A 12 MHz crystal is connected to crystal input pins XTAL1 and XTAL2 that generates required clock signal for micro controller. Two capacitors (33 pF) are connected one with each terminal of crystal as shown. 
 

Circuit Operation:

• When circuit is switched ON the message is displayed on LCD as “This is LCD animation effect  demonstration program” with delay animation effect – means one by one character is displayed with delay 
 
• After 2 sec of delay the first message is displayed “Hello! How are you? This message will scroll left” and this message will continuously scroll left. The message continuously scrolls till new effect button is not pressed
 
• When new effect button is pressed next message is displayed “Hi Have a good day and have a nice time this message will scroll right”. And this message start scrolling right. The message continuously scrolls till button is pressed
 
• Again pressing new effect button will display next message “This is 20×4 LCD this message will scroll up” and message start scrolling from down to up. 
 
• To change next text animation again button is pressed and new message is displayed “this message will scroll down”. The message will start scrolling down
 
• Again press the button. The next message “this message appears and disappears very slow” is displayed as one by one characters appears very slowly. The message appears for few seconds and again starts disappearing character by character very slowly. This cycle continuous till button is pressed
 
• Again when button is pressed, as a last animation effect the message “this message appears and disappears very fast” is displayed as one by one characters appears very fast. The message appears for few seconds and again starts disappearing character by character very fast. This cycle continuous till button is pressed
 
• Again pressing button will display 1st animation effect with text scrolling left
 
• Thus there are 6 different text animation effects displayed one after another as button is pressed
 
Software program and logic:
 
To generate such text animation effects on LCD, the program is embedded in micro controller. Let us understand the logic behind the program.
 
To scroll text left: after displaying complete message on LCD screen, the command 18h is given to LCD continuously to scroll LCD screen continuously left.
 
To scroll text right: after displaying complete message on LCD screen, the command 1Ch is given to LCD continuously to scroll LCD screen continuously right.
 
To scroll text up or down: there is no direct command to scroll text up and down. So to scroll message up or down after displaying complete message it is shifted upward or downward. To scroll message upward, first the message is displayed in 1st, 2nd and 3rd lines of LCD. Then LCD is cleared and message is displayed in 1st and 2nd line only. Again LCD is cleared and message is displayed in only 1st line. Then message starts appearing from 4th line of LCD and moves upward as 4th line – 3rd line – 2nd line – 1st line. Every time message is displayed and LCD is cleared and this creates animation effect as message is scrolling upward. To scroll message downward the reverse has to be done. The message is displayed in 1st and 2nd line then 2nd and 3rd line then 3rd and 4th line and like wise.
 
To display message slow and fast: to display message slow / fast one by one characters are displayed on screen with more / less delay in between. If delay is more the characters appear slowly and if delay is less they appears fast. To make message disappear blank spaces are displayed one by one that will clear the message characters one by one. 

Project Source Code

 

Project Source Code

###


#include <reg51.h>
#include <string.h>
 
#define lcd_databus P2
sbit en = P3^1;
sbit rs = P3^0;
 
unsigned int new_effect_flag=0;
void lcddly()
{
int x;
for(x=0;x<1500;x++);
 }
void delay(unsigned int y)
{
int w,x;
for(w=0;w<y;w++)
 for(x=0;x<1000;x++);
 }
void writecmd(unsigned char a)
{
lcddly();
rs = 0;
lcd_databus = a;
en = 1;
en = 0;
}
void writedat(unsigned char b)
{
lcddly();
rs = 1;
lcd_databus = b;
en = 1;
  en = 0;
}
void writestr(unsigned char *s,unsigned int d)
{
unsigned char l,i;
l = strlen(s);
for(i=0;i<l;i++)
{
writedat(*s);
s++;
    delay(d);
}
}
void writestr_fast(unsigned char *s)
{
unsigned char l,i;
l = strlen(s);
for(i=0;i<l;i++)
{
writedat(*s);
s++;    
}
}
void init_lcd()
{
lcd_databus = 0x00;
rs = 0;
en = 0;
writecmd(0x38);
  writecmd(0x0E);
writecmd(0x06);
  writecmd(0x01);
  writestr("    This is LCD",10);
  writecmd(0xC0);
  writestr("  animation effect",10);
  writecmd(0x94);
  writestr("demonstration program",10);
}
void text_scrolling_right()
  {
new_effect_flag=0;
   writecmd(0x01);
   writestr("Hi! Have a good day",4);
   writecmd(0xC0);
   writestr("and have a nice Time",4);       
   writecmd(0x94);
   writestr("    This message",4);       
   writecmd(0xD4);
   writestr("  will scroll right",4);
   while(new_effect_flag==0){writecmd(0x1C);delay(50);}
}
void text_scrolling_left()
  {
new_effect_flag=0;
   writecmd(0x01);
   writestr("Hello! how are you?",4);
   writecmd(0xC0);
   writestr("     what's up?",4);       
   writecmd(0x94);
   writestr("    This message",4);       
   writecmd(0xD4);
   writestr("  will scroll left",4);
   while(new_effect_flag==0){writecmd(0x18);delay(50);}
}
void text_scrolling_up()
  {
new_effect_flag=0;
while(new_effect_flag==0)
{ 
  writecmd(0x01);
  writestr_fast("  This is 20x4 LCD");
  writecmd(0xC0);
  writestr_fast("    This message");       
         writecmd(0x94);
  writestr_fast("   will scroll up");       
  delay(100);
         writecmd(0x01);
  writestr_fast("    This message"); 
         writecmd(0xC0);
  writestr_fast("   will scroll up");
         delay(100);
         writecmd(0x01);
  writestr_fast("   will scroll up");
         delay(100);
         writecmd(0x01);
  writecmd(0xD4);
  writestr_fast("  This is 20x4 LCD");
         delay(100);
  writecmd(0x01);
  writecmd(0x94);
  writestr_fast("  This is 20x4 LCD");
  writecmd(0xD4);
  writestr_fast("    This message"); 
  delay(100);
  writecmd(0x01);
         writecmd(0xC0);
         writestr_fast("  This is 20x4 LCD");
         writecmd(0x94);
         writestr_fast("    This message"); 
         writecmd(0xD4);
         writestr_fast("   will scroll up");
         delay(100);
} 
}
 void text_scrolling_down()
  {
new_effect_flag=0;
while(new_effect_flag==0)
{
writecmd(0x01);
  writestr_fast("    This message");
  writecmd(0xC0);
  writestr_fast("  will scroll down");       
         delay(100);
         writecmd(0x01);
  writecmd(0xC0);
writestr_fast("    This message");
writecmd(0x94);
writestr_fast("  will scroll down"); 
delay(100);
writecmd(0x01);
 writecmd(0x94);
writestr_fast("    This message");
writecmd(0xD4);
writestr_fast("  will scroll down"); 
delay(100);
writecmd(0x01);
writecmd(0xD4);
writestr_fast("    This message");
writecmd(0x80);
writestr_fast("  will scroll down");
delay(75);
  }
}
 void slow_text_display()
  {
new_effect_flag=0;
 while(new_effect_flag==0)
  {
  writecmd(0x01);
writestr(" This message will",30);
writecmd(0xC0);
writestr("appear and disappear",30);
writecmd(0x94);
writestr("     very slow",30);
delay(200);
writecmd(0x80);
writestr("                   ",30);
writecmd(0xC0);
writestr("                    ",30);
writecmd(0x94);
writestr("              ",30);
}
}
void fast_text_display()
  {
new_effect_flag=0;
 while(new_effect_flag==0)
  {
  writecmd(0x01);
writestr(" This message will",5);
writecmd(0xC0);
writestr("appear and disappear",5);
writecmd(0x94);
writestr("     very fast",5);
delay(200);
writecmd(0x80);
writestr("                   ",5);
writecmd(0xC0);
writestr("                    ",5);
writecmd(0x94);
writestr("              ",5);
}
}
void int0() interrupt 0
  {
new_effect_flag=1;
delay(200);
}
void main()
  {
IE = 0x81;
init_lcd();
delay(200);
while(1)
{
text_scrolling_right();
text_scrolling_left(); 
text_scrolling_up();
text_scrolling_down();
slow_text_display();
fast_text_display();
}
}
 

###

 


Circuit Diagrams

LCD-animation-circuit

Project Video


Filed Under: Electronic Projects
Tagged With: Text on 20x4 LCD using AT89C52 Microcontroller
 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Pull up via GPIO
  • Code Optimization
  • Poly Spacing Effect
  • Thyristor Gate Drive
  • Passive Harmonics Filter

RSS Electro-Tech-Online.com Discussions

  • Someone please explain how this BMS board is supposed to work?
  • HV Diodes
  • Question about ultrasonic mist maker
  • DIY bluetooth speaker
  • Disabled son needs advice please
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering