Hitachi Type 2 x 16 display

I was having difficulty writing long scrolling text to these displays.

I came up with this function, it specifies the text (any length) and the line to write it on.

Maybe it's not cool but it worked for me.

void printLine(String text, int line){

String lcdLine = (" ");// used to get a blank line

lcd.setCursor(0,line);
//print variable clubName
for (x=0; x < text.length(); x++){

if (x>15){
//sorts out the 16 char limit on display by shuffling everything along
for(x1 = 0; x1 < 15; x1++){
char temp = (lcdLine.charAt((x1) + 1));

lcdLine.setCharAt(x1, temp);
}
lcdLine.setCharAt(15,text.charAt(x));
lcd.setCursor(0,line);
lcd.print(lcdLine);

}else{
//prints if message size less than 16
lcdLine.setCharAt(x,text.charAt(x));
lcd.setCursor(0,line);
lcd.print(lcdLine);
}

delay(100);

}
}

Please use the code button to insert code:

I wouldn't put lcd.print() inside of a for loop and print the entire message 16 times although only one print seems necessary.

Here's something I did. Take a look to see if anything is useful to you: