this call just scrolls whatever is on the display left
there is no notion of hidden characters that would be at the end of the line. it just overwrites the characters that are in column 0 with the ones from column1, those from column 1 with the ones from column 2 etc and you get an empty space in the last column.
When you position the cursor somewhere and send some text to print, you need to ensure you don't go past the end of the line otherwise the text will flow to other lines and not in sequence.
On a 2040 LCD (4 lines, 20 positions), if you try to print at (0,0) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?;:=+/$()[]&<>@#-*";
you'll see
that is the first line overflows in the 3rd then you go to the 2nd and then the 4th.
On a 1602 LCD (2 lines, 16 positions) I think the behavior is the same and you'll write to a non existing line 3 after line 1 and come back to line 2 and then a virtual line 4
Are you trying to scroll the message across the first row only?
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const char msg[] = "Hello, this is a long message that will scroll on the screen 1234 abcdefg !@#$%^&*() "; // 16 blank spaces to scroll the text off the line
const int screenWidth = 16, msgSize = sizeof(msg); // chagracters in array
char page[screenWidth]; // a row of characters for the LCD
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
}
void loop() {
for (int i = 0; i < msgSize - screenWidth; i++) { // stop one "row" before end of message
for (int j = 0; j < screenWidth; j++) { // 16 characters
page[j] = msg[i + j]; // create a new page (LCD line) to print
}
lcd.setCursor(0, 0); // cursor home
lcd.print(page); // print new page
delay(100);
}
}
yeah, i wanna have scrolling text on first line and have seperate control for second line ( is it possible to make 1 line scroll left and the other one scroll right?)
The idea from post #5 is to create "pages" the width of one LCD line starting at the character position, counting from 0 to the length of the message. I found later that I needed one screen of "spaces" to have the message scroll off the page.
For scrolling left to right (we normally read left to right, but we scroll right to left)... that's a little strange to impossible to read (coding is not impossible)... who can read a sentence from right to left (end to beginning)?
I would say you do NOT want scrolling left to right.