Advertisement
CleverCode

Arduino lcd scroll

May 6th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  4.  
  5. int pulsante = 8;
  6. int val;
  7. String stringa = "Ciao Mondo!";
  8.  
  9. void setup() {
  10.   pinMode(pulsante, INPUT);
  11.   lcd.begin(16, 2);
  12.   lcd.print(stringa);
  13. }
  14.  
  15. void loop() {
  16.  
  17.   val = digitalRead(pulsante);
  18.  
  19.   if (val == 1) {
  20.     Destra();
  21.   } else {
  22.     Sinistra();
  23.   }
  24. }
  25.  
  26. void Destra() {
  27.   for (int conta = 0; conta < stringa.length(); conta++) {
  28.     lcd.scrollDisplayRight();
  29.     delay(150);
  30.   }
  31. }
  32.  
  33. void Sinistra() {
  34.   for (int conta = 0; conta < stringa.length(); conta++) {
  35.     lcd.scrollDisplayLeft();
  36.     delay(150);
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement