Advertisement
fwilliams

Liquid CrystalD with tilt

Oct 16th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. LiquidCrystal lcd(8, 11, 5, 4, 3, 2);
  3. const int tiltPin= 10;
  4. int currentTilt;
  5. int newTilt;
  6. int oldTilt;
  7. int randomcito;
  8.  
  9. void setup()
  10. {
  11. pinMode(tiltPin, INPUT);
  12. lcd.begin(16, 2);
  13. lcd.print("This is your future");
  14. lcd.setCursor(5, 1);
  15. lcd.print(".....Ask me");
  16. Serial.begin(9600);
  17.  
  18. }
  19.  
  20. void loop()
  21. {
  22. newTilt = digitalRead(tiltPin);
  23. Serial.println(newTilt);
  24. if(newTilt != oldTilt)
  25. {
  26. randomcito= random(1,9);
  27. lcd.clear();
  28. lcd.setCursor(2,0);
  29. lcd.print("My guess is...");
  30. lcd.setCursor(4,1);
  31. switch(randomcito)
  32. {
  33. case 1:
  34.  
  35. lcd.print("Yes");
  36. break;
  37. case 2:
  38. lcd.print("Most likely");
  39. break;
  40. case 3:
  41. lcd.print("Certainly");
  42. break;
  43. case 4:
  44. lcd.print("Who knows?");
  45. break;
  46. case 5:
  47. lcd.print("Unsire");
  48. break;
  49. case 6:
  50. lcd.print("Ha, ha...HA!");
  51. break;
  52. case 7:
  53. lcd.print("Doubtful");
  54. break;
  55. case 8:
  56. lcd.print("Try again...");
  57. break;
  58. }
  59. oldTilt= newTilt;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement