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

How to display custom animations on 16×2 LCD using 8051 microcontroller (AT89C51)- (Part 12/45)

By Himanshu Choudhary

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

  • AT89C51 Microcontroller
  • LCD
  • Preset

Project Video


Filed Under: 8051 Microcontroller
Tagged With: 8051, animation, lcd, microcontroller
 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.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 is a loop calibrator? 
  • 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

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

  • RCF Subwoofer Amplifier PIC16F870-I/SP please help me about hex code
  • What was before microcontrollers ?
  • file edit
  • Measure AC current accurateley (100mA to 10A)
  • 74HC595 creating Fake output

RSS Electro-Tech-Online.com Discussions

  • Control Bare LCD With ATmega328p
  • Need a ducted soldering fan for solder smoke extraction
  • Identify a circuit.
  • Sla ir li ion
  • Question about ultrasonic mist maker
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