Scrolling Left and Right on a 16x2 LCD

Hello,

I am working on a project that utilizes a 16x2 LCD and was wondering if you can scroll the first and/or second lines of the LCD independent of each other. I am using the lcd.scrollDisplayLeft(); function but both lines of the LCD are scrolling to the left. I have tried using the setCursor(x,y); function but that only tells the unit which line to print to. Any suggestions?

Thanks

Any suggestions?

Write your own function for scrolling. It's not that difficult.

Using the shiftdisplayLeft or right function will move everything on the screen, so as PaulS suggests, you need to make your own function.

You will obviously need to input your message, and you will also need conditions (Start from here, stop here, and at what speed). Your message will either be a char pointer / char array or String (preferably don't use). Getting the message to move to the right is easy, use a loop (non-blocking) set the cursor to show the message and increment the cursor. You will also need a blank character to trail the message, to clean up as the message moves.

Now I have a 20x4 so if my message goes off the screen, it will start to appear two lines down. I don't know what happens when your message goes off screen, so the results could be different.

Anyways, in order to shift the message, you need to know how long it is. Depending on how you store it will determine what method you need to use to get its length. Strlen() is good for char arrays and .length() is good for Strings. Now if you know how long the message is, then you can program when to crop the message and when to feed it in. Of course when you crop it, you will want to feed it in, but how would you go about feeding it in? The answer is simple, your message is stored as an array so if you know the length, then you can send out the last character shift it then send out the next one. Rinse and repeat.

The process for left shifting is just the same but backwards. You still need to know the length, but now instead of feeding the last character, your now feeding the first character. Shift, feed, shift, feed.

Nothing to it really. Just make sure you know at what point of the message you need to start to crop and feed it.