LCD 2x16 animation

Status
Not open for further replies.

Paris Heng

New Member
Dear,

I now doing some animation (moving text/scrolling text) in the LCD 2x16. How to do that? Any example code? I can't find any. I just want to do a simple moving the text from left to right and continuously moving. Please help.
 
Last edited:
Paris Heng said:
Dear,

I now doing some animation (moving text/scrolling text) in the LCD 2x16. How to do that? Any example code? I can't find any. I just want to do a simple moving the text from left to right and continuously moving. Please help.

hi,
Its like this;
movlw 0x1C;move all 1 right
call lcd_cmd

movlw 0x18; move all 1 left
call lcd_cmd

Do you follow.?

EDIT: which PIC are you using and how do you have it connected.?
 
Last edited:
ericgibbs said:
hi,
Its like this;
movlw 0x1C;move all 1 right
call lcd_cmd

movlw 0x18; move all 1 left
call lcd_cmd

Do you follow.?

EDIT: which PIC are you using and how do you have it connected.?

AT80S52. But i write in C code. Can you show me the C code? I am newbie. What is 0x1C? and 0x18 for? It is for LCD position?

Thank your reply again.
 
Last edited:
Those are control codes for the LCD - basically most LCD's are really 2x40 in size, with the actual display a 'window' on to that screen buffer. Those control codes scroll the window along the buffer.
 
hi.
As Nigel points out these are control codes for the LCD.

You must have initialised the LCD anyway in 'C' in order to display text.?

So, use the same LCD command instruction call that you used to initialise the LCD, except insert the 1CHand 18H to do SHIFTs.

If you dont follow, post the initialise code section from your 'C' program and we will try to help...
 

The code i actually refer to Ajay Bhargav from 8051 forum. Below is the code for the LCD,

lcd.c


lcd.h
#ifndef __LCD_H__
#define __LCD_H__

#include "ports.h"

void wrt_cmd(bit_8);
void wrt_data(bit_8*);
void LCD_INI(void);
void busy(void);
void wrt_byte(bit_8);
void build_ram();
void disp_const(void);
void disp_intro(void);

#endif

How to write the scrolling text? Example I wan to scroll a test "Welcome". I want to scroll the text in void disp_intro(). Mean the intro.

Please assist with some basic C code.
 
Last edited:
hi,
I am not a 'C' programmer, but this section looks like the init code for the LCD

void LCD_INI(void)
{
wrt_cmd(0X38);
wrt_cmd(0X0C);
wrt_cmd(0X01);
wrt_cmd(0X06);
}

Write your message to the LCD, so that its visible then
try something like

{wrt_cmd(0x1C)} for Right SHIFT

Perhaps a member who uses 'C' will give more help.
 

I try 1st, hope someone use C can help me
 
Eric is correct, you need to write command 0x18 to scroll left and 0x1c to scroll right.

This will scroll the display around once.
Code:
    for(i=0;i<40;i++){
        wrt_cmd(0x18);
        DelaymS(100);
    }

Mike.
 
SCROLLING TEXT ON 2x16 LCD USING 8051

May be this code helps you...there may be much room for improvement of this code but i am not very much concerned with it...my main concern is the i want it improved in this regard that it should keep on scrolling the text of any lenght without breaks whereas below given code does not do it for me...
thanx in advance.



;----------------------------------------------------------------------
;----------------------------------------------------------------------
DB0 EQU P1.0
DB1 EQU P1.1
DB2 EQU P1.2
DB3 EQU P1.3
DB4 EQU P1.4
DB5 EQU P1.5
DB6 EQU P1.6
DB7 EQU P1.7
RS EQU P3.3
RW EQU P3.4
EN EQU P3.5

ORG 300H
DB "THIS CODE IS WRITTEN BY MEHMOOD AHMED FOR 8051"
DB "MICROCONTROLLER",0

ORG 00H
START:
ACALL INITLCD
MOV A,#0H
MOV DPTR,#0300H
MAIN:
ACALL COMMANDDELAY
CLR EN
PUSH ACC
CJNE A,#170,ISLESS
CALL SCROLLDELAY
MOV A,#0H
ISLESS:
JZ HERE
MOV B,#40
DIV AB
MOV A,B
JNZ HERE
MOV A,#02H
ACALL COMMAND
HERE:
POP ACC
PUSH ACC
MOVC A,@A+DPTR
ACALL WRITECOMMAND
POP ACC
INC A
LJMP MAIN
COMMAND:
CLR RS
CLR RW
MOV P1,A
SETB EN
ACALL COMMANDDELAY
CLR EN
RET
WRITECOMMAND:
ACALL SCROLLDELAY
ACALL SCROLLDELAY
SETB RS
CLR RW
MOV P1,A
SETB EN
ACALL COMMANDDELAY
CLR EN
RET
INITLCD:
MOV A,#30H
ACALL COMMAND
MOV A,#30H
ACALL COMMAND
MOV A,#30H
ACALL COMMAND
MOV A,#07H
ACALL COMMAND
MOV A,#0cH
ACALL COMMAND
;MOV A,#010h
;ACALL COMMAND
RET
COMMANDDELAY:
MOV R1,#20H
LOOP2: MOV R0,#20H
LOOP1: DJNZ R0,LOOP1
DJNZ R1,LOOP2
RET
SCROLLDELAY:
MOV R3,#2H
LOOPX3:
MOV R2,#90H
LOOPX2: MOV R1,#90H
LOOPX1: DJNZ R1,LOOPX1
DJNZ R2,LOOPX2
DJNZ R3,LOOPX3
RET
LCDWAIT:
PUSH ACC
CLR A
WAIT:
CLR RS
SETB WR
SETB EN
MOV P1,#0FFH
MOV A,P1
CLR EN
JB ACC.7,WAIT
POP ACC
RET
END
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…