Scrolling Text
Part of the Displays and Sensors section of Coddy's Arduino journey. Lesson 11 of 24.
Text longer than 16 characters does not fit, but it can slide past like a news ticker.
lcd.scrollDisplayLeft() moves everything on the screen one column to the left. The letters stay in the screen's memory; only the view moves. Call it again and again, with a pause, and the text slides:
void loop() {
lcd.scrollDisplayLeft();
delay(300);
}Each row of the screen's memory is 40 characters long and the 16 columns are a window on it. Keep scrolling and the text leaves on the left, and after 40 steps it comes back round from the right.
lcd.scrollDisplayRight() slides the other way. Without the delay(), the text moves so fast nobody can read it.
Challenge
EasyThe starter prints Hello, world!. Make it slide:
- move the text one place to the left every 300 ms, with
lcd.scrollDisplayLeft()
Press Run and watch it scroll, then Check.
Try it yourself
#include <LiquidCrystal.h>
// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("Hello, world!");
}
void loop() {
// move the text one place to the left every 300 ms
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Displays and Sensors
1Seven-Segment Displays
Seven-Segment DisplayDigit Patterns in BytesCount on the DisplayCountdown to ZeroDice Roller2Character LCD
Hello on the LCDPlace Text with setCursorLive Numbers on the LCDClear Leftover DigitsDraw Custom CharactersScrolling TextPractice on your own: Arduino playground