How to create text animation on 16x2 LCD using 8051 microcontroller (AT89C51)


A static message can be displayed on a 16x2 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.

Text animation on LCD using 8051 Microcontroller (AT89C51)


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.  The different command codes for LCD are tabulated below:


Hex Code
Command to LCD Instruction Register
Clear screen display
Return home
Decrement cursor
Increment cursor
Shift display right
Shift display left
Display OFF, cursor OFF
Display OFF, cursor ON
Display ON, cursor OFF
Display ON, cursor blinking
Shift cursor position to left
Shift cursor position to right
Shift the entire display to the left
Shift the entire display to the right
Force the cursor to the beginning of the 1st line
Force cursor to the beginning of the 2nd line
Use 2 lines and 5x7 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.
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 preset of 10k to adjust the contrast on LCD screen.

Circuit Diagram





Presets | Variable Resistors
AT89C51 Microcontroller, Atmel 89C51 Controller Image
AT89C51 Microcontroller


16 x 2 LCD | 16x2 Character LCD Module



You are here