Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_RGBLCDShield.h>
- #include <utility/Adafruit_MCP23017.h>
- Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
- void setup() {
- lcd.begin(16, 2); //format of display
- }
- int menu = 0;
- int subMenu = 99;
- int debounce = 200;
- unsigned long pMillis = 0,
- cMillis;
- void loop() {
- uint8_t buttons = lcd.readButtons();
- cMillis = millis(); // sets cMillis to current millis()
- lcd.setCursor(0,0);
- if(cMillis >= (pMillis + debounce)){
- if (menu == 0) {
- lcd.print("Select menu option");
- if (buttons & BUTTON_SELECT) {
- lcd.clear();
- menu = 99;
- subMenu = 1;
- }
- }
- if (subMenu == 1) {
- lcd.print("in sub menu 1");
- if (buttons & BUTTON_SELECT) {
- lcd.clear();
- lcd.setCursor(0,1);
- lcd.print("shouldnt happen");
- }
- }
- pMillis = cMillis; // sets pMillis to cMillis for the next iteration of the loop()
- }
- if(cMillis < pMillis){
- pMillis = cMillis; // sets pMillis to cMillis for the next iteration of the loop()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement