Skip to content

Instantly share code, notes, and snippets.

@RecNes
Created November 18, 2016 17:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RecNes/2b199bac521158a9983891fe6df39721 to your computer and use it in GitHub Desktop.
Save RecNes/2b199bac521158a9983891fe6df39721 to your computer and use it in GitHub Desktop.
Arduino gist for proper usage of vertical scrolling on each output with 16x2 LCD display.
#include <LiquidCrystal.h>
String Line1;
String Line2;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void lcdPrint(String lcdText) {
lcd.clear();
Line1 = Line2;
lcd.setCursor(0, 0);
lcd.print(Line1);
Line2 = lcdText;
Line2.replace("\r\n", "");
lcd.setCursor(0, 1);
lcd.print(Line2);
Line1 = "";
lcdText = "";
}
void setup() {
lcd.begin(16, 2);
lcdPrint("LCD Initialized!");
lcdPrint("DEMO LINE 1");
lcdPrint("DEMO LINE 2");
lcdPrint("DEMO LINE 3");
lcdPrint("DEMO LINE 4");
lcdPrint("DEMO LINE 5");
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment