Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <Adafruit_RGBLCDShield.h>
  2. #include <utility/Adafruit_MCP23017.h>
  3. Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
  4.  
  5.  
  6. void setup() {
  7. lcd.begin(16, 2); //format of display
  8. }
  9.  
  10. int menu = 0;
  11. int subMenu = 99;
  12.  
  13. int debounce = 200;
  14. unsigned long pMillis = 0,
  15. cMillis;
  16.  
  17. void loop() {
  18. uint8_t buttons = lcd.readButtons();
  19.  
  20. cMillis = millis(); // sets cMillis to current millis()
  21.  
  22. lcd.setCursor(0,0);
  23. if(cMillis >= (pMillis + debounce)){
  24.  
  25. if (menu == 0) {
  26. lcd.print("Select menu option");
  27. if (buttons & BUTTON_SELECT) {
  28. lcd.clear();
  29. menu = 99;
  30. subMenu = 1;
  31. }
  32. }
  33.  
  34. if (subMenu == 1) {
  35. lcd.print("in sub menu 1");
  36. if (buttons & BUTTON_SELECT) {
  37. lcd.clear();
  38. lcd.setCursor(0,1);
  39. lcd.print("shouldnt happen");
  40. }
  41. }
  42. pMillis = cMillis; // sets pMillis to cMillis for the next iteration of the loop()
  43. }
  44.  
  45. if(cMillis < pMillis){
  46. pMillis = cMillis; // sets pMillis to cMillis for the next iteration of the loop()
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement