Need help displaying moving text on a 16x2 LCD

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help displaying moving text on a 16x2 LCD

Jump to solution
7,048 Views
admin
Specialist II
Hello everyone. I have a 16x2 LCD and I am able to display text on the LCD but I want to make the text moving, like having the text moving from right to left of the LCD instead of stationery text. Can anyone help me? Thx :smileyhappy:
Labels (1)
Tags (1)
0 Kudos
1 Solution
1,706 Views
admin
Specialist II

Thx for the replies. I followed BlackNight's example. Not sure how to utilise BigMac's example lol. Here's how I programmed it for those who would like to know:

 

if (config == shift)
        {
             //shift display
             LCDrs = 0;
             LCDdata = 0b00011000; 
             wait;
             LCDenable = 1;
             wait;
             LCDenable = 0;
             wait;
         }

 

Cheers :smileyhappy:

View solution in original post

0 Kudos
4 Replies
1,707 Views
admin
Specialist II

Thx for the replies. I followed BlackNight's example. Not sure how to utilise BigMac's example lol. Here's how I programmed it for those who would like to know:

 

if (config == shift)
        {
             //shift display
             LCDrs = 0;
             LCDdata = 0b00011000; 
             wait;
             LCDenable = 1;
             wait;
             LCDenable = 0;
             wait;
         }

 

Cheers :smileyhappy:

0 Kudos
1,706 Views
BlackNight
NXP Employee
NXP Employee

Hello,

that will depend of course of the LCD display controller used. If you are using one of the common Hitachi or HD44780 or compatible, then there are two special commands which allow you to shift the content in the display:

#define RightShift     0x1C
#define LeftShift      0x18

void LCD_Shift (unsigned char Right)
{
   if (Right)
      WriteLCDCommand (RightShift);
   else
      WriteLCDCommand (LeftShift);
}

 

Of course you would have to use your own routine to send the commands (which are pretty timing sensitive).

 

BN

0 Kudos
1,706 Views
bigmac
Specialist III

Hello,

 

An alternative to BN's suggestion is to make use of the "Entry mode set" command, rather than the cursor/display shift command.  Reference to these commands can be found within AN1745.  Here is an extract from the application note:

Entry Mode Set

 

I/D — Increments (I/D = 1) or decrements (I/D = 0) the DDRAM address by 1 when a character code is written into or read from DDRAM. The cursor or blinking moves to the right when incremented by 1 and to the left when decremented by 1. The same applies to writing and reading of CGRAM.

 

S — Shifts the entire display either to the right (ID = 0) or to the left (I/D = 1) when S is 1. The display does not shift if S is 0. If S is 1, it will seem as if the cursor does not move but the display does. The display does not shift when reading from DDRAM. Also, writing into or reading out from CGRAM does not shift the display.

To set the mode that you require would need a command value of 0x07.

 

The advantage of this method would seem that the left shift of the display would occur automatically whenever each character was written.  With the previous method, the display shift command would need to be given prior to writing each character to the display.

 

Regards,

Mac

0 Kudos
1,706 Views
peg
Senior Contributor IV

Hello,

 

Also be aware that as the controller is made for larger displays you can use the memory off the edge of your display to write a long message into and then scroll backwards and forwards through it. This can be used with either of the methods suggested above. However this makes it tricky to scroll one line to another and scroll only one line.

 

0 Kudos