LCD going to next line

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);
  }
}
1 Like