Facebook
From Mungo Stork, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 65
  1. #include <LiquidCrystal.h>
  2. #define RS 12
  3. #define EN 11
  4. #define D4 5
  5. #define D5 4
  6. #define D6 3
  7. #define D7 2
  8. #define PULSANTE 6
  9. #define NFRASI 10
  10.  
  11. LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);
  12.  
  13. char frasi[NFRASI][16] = {
  14.   "",
  15.   "A<3",
  16.   "B",
  17.   "C",
  18.   "D",
  19.   "E",
  20.   "F",
  21.   "G",
  22.   "H",
  23.   "I",
  24. };
  25.  
  26. char visFrase = 0;
  27. char old_visFrase = 0;
  28. char old_button;
  29.  
  30. void setup() {
  31.   lcd.begin(16, 2);
  32.   pinMode(PULSANTE, INPUT);
  33. }
  34.  
  35. void loop() {
  36.   char button = digitalRead(PULSANTE);
  37.  
  38.   if (button == LOW && old_button == HIGH)
  39.   {
  40.     visFrase++;
  41.     if (visFrase > NFRASI - 1) visFrase = 0;
  42.   }
  43.   old_button = button;
  44.  
  45.   if (visFrase != old_visFrase)
  46.   {
  47.     lcd.clear();
  48.     lcd.setCursor(0, 0);
  49.     lcd.print(frasi[visFrase]);
  50.     old_visFrase = visFrase;
  51.   }
  52. }
  53.