Created
December 18, 2019 13:11
-
-
Save techzeero/9c512f06d8b887b61070b85bcd0d26f5 to your computer and use it in GitHub Desktop.
Scrolling Text on LCD 16x2 - https://techzeero.com/arduino-tutorials/how-to-use-an-lcd-display-with-arduino/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Scrolling Text on LCD 16x2 | |
For more details, visit: https://techzeero.com/arduino-tutorials/how-to-use-an-lcd-display-with-arduino/ | |
*/ | |
#include<LiquidCrystal.h> | |
LiquidCrystal lcd(12,11,5,4,3,2); | |
int numRows = 2; | |
int numCols = 16; | |
void setup() | |
{ | |
lcd.begin(numCols, numRows); | |
} | |
void loop() | |
{ | |
marquee("A message is too long to fit !"); | |
delay(1000); | |
lcd.clear(); | |
} | |
void marquee(char *text) | |
{ | |
int length = strlen(text); | |
if(length < numCols) | |
lcd.print(text); | |
else | |
{ | |
int pos; | |
for(pos = 0; pos < numCols; pos++) | |
lcd.print(text[pos]); | |
delay(1000); | |
while(pos < length) | |
{ | |
lcd.scrollDisplayLeft(); | |
lcd.print(text[pos]); | |
pos = pos + 1; | |
delay(300); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment