Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. // initialize the library with the numbers of the interface pins
  3. LiquidCrystal lcd (4, 6, 10, 11, 12, 13);
  4. const int tiltPin= 7;
  5. int newTilt; // variable to read the tilt
  6. int oldTilt;
  7.  
  8. void setup() {
  9. // set up the number of columns and ros on the LCD
  10. lcd.begin (16,2);
  11. lcd.setCursor (5,0);
  12. lcd.print ("This is your future");
  13. // set the cursor to column o, line 1
  14. //line 1 is the second row, since counting begins with 0
  15. lcd.setCursor (1,1) ;
  16. //print to the second line
  17. lcd.print ("......Ask me");
  18. Serial.begin(9600);
  19.  
  20.  
  21. }
  22.  
  23. void loop() {
  24.  
  25. newTilt = digitalRead (tiltPin);
  26. Serial.println (newTilt) ;
  27.  
  28. if (newTilt != oldTilt) //making sure that we have moved the board
  29. {
  30. int randomcito = random (1,9);
  31.  
  32. lcd.clear ();
  33. lcd.setCursor (2,0);
  34. lcd.print ("My guess is...");
  35. lcd.setCursor (2,1);
  36. switch (randomcito)
  37. {
  38. case 1:
  39. lcd.print (" yes ");
  40. break;
  41. case 2:
  42. lcd.print (" most likely ");
  43. break;
  44. case 3:
  45. lcd.print (" nope ");
  46. break;
  47. case 4:
  48. lcd.print (" HAHAHA ");
  49. break;
  50. case 5:
  51. lcd.print (" you wish ");
  52. break;
  53. case 6:
  54. lcd.print (" certainly ");
  55. break;
  56. case 7:
  57. lcd.print (" you will fail ");
  58. break;
  59. case 8:
  60. lcd.print (" who knows? ");
  61. break;
  62.  
  63. }
  64.  
  65.  
  66.  
  67.  
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement