weinerm21

Untitled

Jun 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. // include the library code:
  2. #include <LiquidCrystal.h>
  3.  
  4. // initialize the library with the numbers of the interface pins
  5. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  6.  
  7. // set up a constant for the tilt switch pin
  8. const int switchPin = 6;
  9.  
  10. // variable to hold the value of the switch pin
  11. int switchState = 0;
  12.  
  13. // variable to hold previous value of the switch pin
  14. int prevSwitchState = 0;
  15.  
  16. // a variable to choose which reply from the crystal ball
  17. int reply;
  18.  
  19. void setup() {
  20. // set up the number of columns and rows on the LCD
  21. lcd.begin(16, 2);
  22.  
  23. // set up the switch pin as an input
  24. pinMode(switchPin, INPUT);
  25.  
  26. // Print a message to the LCD.
  27. lcd.print("Ask the");
  28. // set the cursor to column 0, line 1
  29. // line 1 is the second row, since counting begins with 0
  30. lcd.setCursor(0, 1);
  31. // print to the second line
  32. lcd.print("Crystal Ball!");
  33. }
  34.  
  35. void loop() {
  36. lcd.print("Ask the");
  37. // set the cursor to column 0, line 1
  38. // line 1 is the second row, since counting begins with 0
  39. lcd.setCursor(0, 1);
  40. // print to the second line
  41. lcd.print("Crystal Ball!");
  42. // // check the status of the switch
  43. // switchState = digitalRead(switchPin);
  44. //
  45. // // compare the switchState to its previous state
  46. // if (switchState != prevSwitchState) {
  47. // // if the state has changed from HIGH to LOW you know that the ball has been
  48. // // tilted from one direction to the other
  49. // if (switchState == LOW) {
  50. // // randomly chose a reply
  51. // reply = random(8);
  52. // // clean up the screen before printing a new reply
  53. // lcd.clear();
  54. // // set the cursor to column 0, line 0
  55. // lcd.setCursor(0, 0);
  56. // // print some text
  57. // lcd.print("the ball says:");
  58. // // move the cursor to the second line
  59. // lcd.setCursor(0, 1);
  60. //
  61. // // choose a saying to print based on the value in reply
  62. // switch (reply) {
  63. // case 0:
  64. // lcd.print("Yes");
  65. // break;
  66. //
  67. // case 1:
  68. // lcd.print("Most likely");
  69. // break;
  70. //
  71. // case 2:
  72. // lcd.print("Certainly");
  73. // break;
  74. //
  75. // case 3:
  76. // lcd.print("Outlook good");
  77. // break;
  78. //
  79. // case 4:
  80. // lcd.print("Unsure");
  81. // break;
  82. //
  83. // case 5:
  84. // lcd.print("Ask again");
  85. // break;
  86. //
  87. // case 6:
  88. // lcd.print("Doubtful");
  89. // break;
  90. //
  91. // case 7:
  92. // lcd.print("No");
  93. // break;
  94. // }
  95. // }
  96. // }
  97. // // save the current switch state as the last state
  98. // prevSwitchState = switchState;
  99. }
Add Comment
Please, Sign In to add comment