So I've been trying to make a function for scrolling the text on a 16x2 with I2C and I got it working, but i'd want the string of characters to start behind the first column, when it gets to the second row, to give it a "scrollier" effect. I thought about setting the cursor to something like (-col, row) but... it doesn't really work. Here is the code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
lcdscroll("abcdefgh");
}
void lcdscroll(String printvar) {
int sizevar = printvar.length();
int minussizevar = (0 - sizevar);
int y = 300;
start:
for (int i = 0; i < 32; i++) {
if (i >= 17) {
for (int j = 0; minussizevar < j < 17; j++) {
lcd.clear();
lcd.setCursor(j, 1);
lcd.print(printvar);
delay(y);
if (j == 16) {
goto start;
}
}
}
else {
lcd.clear();
lcd.setCursor(i, 0);
lcd.print(printvar);
delay(y);
}
}
}
Can anyone please help me?
Thanks a lot.