Arduino - lcd.scrollDisplayLeft()
Description
Scrolls the contents of the display (text and cursor) one space to the left.
Syntax
lcd.scrollDisplayLeft()
Parameters
- lcd: a variable of type LiquidCrystal
Example
Hardware Required
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
Arduino Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 12, 2, 3, 4, 5);
void setup() {
lcd.begin(16, 2); // set up the LCD 16x2
lcd.print("hello, world!"); // print a message to the LCD
delay(1000);
}
void loop() {
// scroll 13 positions (string length) to the left to move it offscreen left:
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
lcd.scrollDisplayLeft(); // scroll one position left:
delay(150); // wait a bit
}
// scroll 29 positions (string length + display length) to the right to move it offscreen right:
for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
lcd.scrollDisplayRight(); // scroll one position right
delay(150); // wait a bit
}
// scroll 16 positions (display length + string length) to the left to move it back to center:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
lcd.scrollDisplayLeft(); // scroll one position left
delay(150); // wait a bit
}
delay(1000); // delay at the end of the full loop:
}
See Also
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |