#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
//                  123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1234 = 84
const char msg[] = "Hello, this is a long message that will scroll on the screen 1234 abcdefg !@#$%^&*()";

int col = 0, row = 0, screenWidth = 16;
int msgSize = sizeof(msg); // chagracters in array
int pageCount = msgSize / 32 + 1; // pages of 32 in array, first page is 1
int page; // current page

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
}

void loop() {
  if (page == pageCount) // check page inside array
    pageCount = 0; // reset page number

  if (col == screenWidth) { // check column number
    col = 0; // reset column
    if (row) { // if second row...
      page++; // next page
      lcd.clear(); // clear screen
    }
    row = !row; // check row and reset row... by alternating 0 and 1
  }

  lcd.setCursor(col, row); // place the cursor
  lcd.write(msg[col + (row * 16) + (page * 32)]); // place next character
  col++; // next column of 16
  delay(100);

  if ((col + (row * 16) + (page * 32)) > msgSize)
    while (1); // stop printing
}