Scrolling text animation in 16×2 LCD |
LCD’s are widely used where user interaction with the system is necessary and you might have come across static message display using LCD. The message displayed on the LCD can also be animated like blinking, scrolling etc. This article explains how to display a running or animated scrolling text in a 16 x 2 LCD display with a 8051 Microcontroller.
16 x 2 LCD:
16×2 LCD Display |
In a 16 x 2 LCD a message is displayed by means of configuring it through commands initially and data to be displayed is sent. A two registers namely Command and Data register are used to serve this purpose in a LCD. Learn about programming LCD if you are not aware of it.
It only take few extra steps to make text scrolling in a LCD screen. There are two specific commands which we use for the purpose of text scrolling. They are
0x18 – Shift Entire Display Left
0x1C- Shift Entire Display Right
Using these commands we have to shift our message either left or right continuously by means of placing it in an infinite loop. Doing this we can achieve the scrolling effect of Message in LCD from right to left or vice versa.
CODE:
#include<reg51.h> #include<string.h> void delay(void); sbit rs=P3^0; sbit rw=P3^1; sbit en=P3^2; code unsigned char a[3]={0x38,0x0f,0x06}; code unsigned char b[12]="GADGETRONICX"; unsigned int i,j,k,l; void cmdwrite() { rs=0; rw=0; en=1; delay(); en=0; } void datawrite() { rs=1; rw=0; en=1; delay(); en=0; } void delay() { for(k=1;k<4000;k++); { for(l=1;l<=5000;l++); } } void main() { for(i=0;i<=2;i++) { P1=a[i]; cmdwrite(); delay(); } P1=0x80; cmdwrite(); delay(); for(j=0;j<=11;j++) { P1=b[j]; datawrite(); } while(1) { P1=0x18; cmdwrite(); delay(); } }
which compiler did you use?
I would like to attach a file on Keil C code.
How can I attach a file to the code.. What are the modifications that I should make in the code.
Please let me know the exact code that includes this attaching
The file that I would like to attach should contain the texts that I want to display on 16×2 LCD display
Praisy Samuel,
I don’t think MCU’s have the capability to deal with files. So you cannot attach or use a file, you could if you add an external memory such as memory card but still you need to interpret them as per their format. All you can do is include the characters in a array and use them.
Plz tell in place of sentence how we can access a .txt file
Hi Kalyani,
Am not sure what you mean .txt file. If you mean to ask to display the characters in a .txt file, then the answer is you cannot do it. You should copy all the characters from the .txt file and then paste it in 8th line in this code instead of “Gadgetronicx”. Remember to extend the array size as per your requirement
in place of sentance how we a .txt file