I am a beginner at Arduino, and am trying to program a 16x2 LCD screen. I wrote a program to to make the text scroll across the screen until it disappears, then clear and reset.
I discovered that when I enter a long line of text, any digits after the 24th drop down to the second line. Can anyone tell me why this would be?
This is my code:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
// set the cursor to (16,0):
lcd.setCursor(16, 0);
// establish the string
String Str1 = "What about a longer line?";
lcd.autoscroll();
//print character by character for the length of the string
for (int n = 0; n < Str1.length(); n++) {
lcd.print(Str1.charAt(n));
delay(300);
}
// scroll 16 positions (display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayLeft();
// wait a bit:
delay(300);
}
lcd.clear();
delay(300);
}
When I load the code, it scrolls something like this:
What about a longer line
?
Anyone know why this might be happening?