Text Animation On LCD Using 8051 Microcontroller

Posted: September 16, 2014 in মাইক্রোকন্ট্রোলার
Tags: , , , ,

A Project
ON
Text Animation On LCD Using 8051 Microcontroller

BY

MD. Sayed Hossain Mondol

Project Name:- Text Animation On LCD Using 8051 Microcontroller .

Objective:-

  • To understand microcontroller techniques .
  • To understand how to interfacing a LCD module with 8051 microcontroller.

Theory :-

                 A static message can be displayed on a (16×2) LCD by interfacing it to the    microcontroller (AT89C51). The same message can also be displayed with certain animated effects like moving, blinking etc. This topic explains how to create dynamic effects with the text displayed in LCD. A string or message can be displayed on LCD by sending its characters to data register after configuring the command register of LCD. To create dynamic effects, a specific command instruction is sent to LCD via microcontroller AT89C51. A 16×2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in (5×7) pixel matrix.

 AT89C51_1HD44780_pins

Fig(a):-   AT89C51 microcontroller                                      Fig(b):-   LCD display (16×2)

Circuit Diagram Of Text Animation On Lcd Using (AT89C51):-

How to create text animation on 16x2 LCD using AT89C51

Fig:- Circuit diagram of text animation on lcd using 8051 microcontroller

Components Required:-

  1. AT89C51 microcontroller.
  2. LCD display (16×2).
  3. Resister 10k, VR 10k.
  4. Capacitors 10µf (25v).
  5. Crystal oscillator 12MHz.
  6. Dc power supply.
  7. Wire.

Working Principle Of Text Animation On Lcd Using 8051 MC:-

  • The circuit is divided into two units: the controller unit and the display unit. The controller unit consists of a microcontroller (AT89C51) circuit.The display unit consists of a LCD. The different command codes for LCD are tabulated below:
Hex Code Command to LCD Instruction Register
1 Clear screen display
2 Return home
4 Decrement cursor
6 Increment cursor
5 Shift display right
7 Shift display left
8 Display OFF, cursor OFF
A Display OFF, cursor ON
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
C Display ON, cursor OFF
E Display ON, Cursor ON
80 Force the cursor to the beginning of the 1st line
C0 Force cursor to the beginning of the 2nd line
38 Use 2 lines and 5×7 matrix
  • To create a particular effect, any of these code(s) can be used in a pattern. For example, shifting the entire display right (5H) in a loop will keep moving the text to right. To create oscillating text, first keep shifting the string to right (for say, 8 positions) and then shift it to left. This left-right shifting can be done in an infinite loop.
  • This microcontroller has 40 pins with four 8-bit ports (P0, P1, P2, and P3).Here P2 is used as output port of the 8051 microcontroller (AT89C51) which sends the data byte to data pins of the LCD. The control pins (pin 4, 5 & 6) are connected to pins 0,1 & 6 respectively of P3 port of the microcontroller. Pin 3 is connected to a of 10k Variable Register to adjust the contrast on LCD screen.
  • To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed on the positive edge of the Enable signal. To send a command on the LCD, the data pins with R/W = 0 and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.

Code:-

// Program to display dynamic text on LCD

 #include<reg51.h>
#define msec 50
sbit rs=P3^0;  //Register select (RS)
sbit rw=P3^1; //Read write (RW) pin
sbit en=P3^6;   //Enable (EN) pin
unsigned char commands[]={0x38,0x0E,0x01,0x06,''}; //Command to be sent to LCD
char name[]={"Sagar ,ECE-106 ,MIU"};   //String to be displayed on LCD

void delay(unsigned int time) //Time delay function
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char value) //Function for sending values to the command register of LCD
{
P2=value;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void display(unsigned char value) //Function for sending values to the data register of LCD
{
P2=value;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void main()
{
int i,j;
for(i=0;commands[i]!='';i++) //Sending string to LCD
{
lcdcmd(commands[i]);
delay(msec);
}
for(j=0;name[j]!='';j++)
{
display(name[j]);
delay(msec);
}
while(1)
{
lcdcmd(0x1C); //Shift the entire display to right
delay(75);
}
}

Applications:-

  • Notice Board.
  • Bill Board.
  • Entertainment Toys.

Discussion:-

                It is very important to keep a track of the working of almost all the automated and semi-automated devices, be it a washing machine, an autonomous robot or anything else. This is achieved by displaying their status on a small display module. LCD (Liquid Crystal Display) screen is such a display module and a 16×2 LCD module is very commonly used. These modules are replacing seven segments and other multi segment LEDs for these purposes. The reasons being: LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. LCD can be easily interfaced with a microcontroller to display a message or status of a device.

20140824_171044

 ফেসবুক এ আমি :  S@G@R

 

Leave a comment