Working, it was because of this statement:
if (msg[x + y - 1] == '\0') break; // wrong because on the first passage on the loop x+y-1 = -1
if (msg[x + y] == '\0') break; // better
Only thing, I put the minus 1 because the message stopped scrolling at the char before the last one. So now I just have to be sure that I put a space or some other char that won't be displayed at the end of the char[].
Final code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 13, 8, 9, 5, 11);
int x;
int y;
char myMsg[128];
void setup() {
Serial.begin(9600);
delay(500);
lcd.begin(16, 2);
lcd.print("Bienvenue");
delay(2000);
}
void loop() {
strcpy(myMsg, "message message message message message ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TEST: ");
scroll(myMsg,1);
delay(1000);
}
void scroll(char msg[], int pos){
for (x = 0; x < strlen(msg) - 1; x++){
if (msg[x + y] == '\0') break;
for (y = 0; y < 16; y++){
if (msg[x + y] == '\0') break;
lcd.setCursor(y,pos);
lcd.print(msg[x+y]);
}
if (x == 0) {delay(1000);}
delay(200);
}
delay(1000);
}
Thank you again,
Simon