I am trying to create a state machine that loops in whatever state it's in until a button is pressed. I am using the Adafruit_RGBLCDShield library along with the LCD shield and 16x2 display. For some reason the buttons aren't being detected at all. Here is the code for one of the states:
case STANDBY_MODE:
lcd.clear();
lcd.setBacklight(0x0);
delay(100);
noInterrupts();
digitalWrite(fire, LOW);
digitalWrite(chg, LOW);
digitalWrite(trig, LOW);
analogWrite(eprgm, 0);
// Wait for button press
while(1)
{
button = lcd.readButtons();
if(button)
{
showLCD();
t0 = millis();
state = NO_CHARGE;
analogWrite(eprgm, (vSet*0.0204)/5);
interrupts();
return;
}
}
break;
In this state, the system turns off all outputs and display and waits for a button to be pressed. For some reason, though, it doesn't respond when I press the button. Is there something missing here?