hi all,
I try to make a simple menu on the LCD display, with switch / case
menu should be in the form:
menu1
menu2 -- submenu21 -- submenu22
menu3
here is the piece of code that does not work
I used button.h
the problem is with the 2nd "if", there in no action when I press button3
void state() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0);
// Print a message to the LCD.
//lcd.print("Voltage:");// print the number of seconds since reset:
//lcd.setCursor(0, 1);
//val = analogRead(analogPin);
//lcd.print(val/204.8);
//lcd.print(millis()/1000);
//lcd.print(" V");
//lcd.setCursor(7, 1);
if(button1.uniquePress()){
Serial.println("B1");
button1Presses = ++button1Presses % NUMBER_OF_STATES1;
switch (button1Presses) {
case 0: lcd.clear();
lcd.setCursor(4, 0);
lcd.print("SET TEMP");
Serial.println("Case0");
break;
case 1: lcd.clear();
lcd.setCursor(2, 0);
lcd.print("SET SELECTOR");
Serial.println("Case1");
if(button3.uniquePress()){
Serial.println("B2");
button3Presses = ++button3Presses % NUMBER_OF_STATES2;
switch (button3Presses) {
case 'sel1':
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SELECTOR1");
break;
case 'sel2':
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SELECTOR2");
break;
}
}
break;
case 2:
lcd.clear();
do {
button1State = digitalRead(button1Pin);
//lcd.clear();
lcd.setCursor(2, 0);
lcd.print("TEMP: ");
lcd.setCursor(0, 1);
val = analogRead(analogPin);
lcd.print(val/204.8);
delay(10);
} while (button1State == LOW);
Serial.println("Case2");
break;
}
}
What is wrong in my code?