This is just a "working" exemple of my problem. In the loop function changes the button value, and it should print to the serial monitor "DOWN" and "UP", but only the first is printed. But if comment the bool variable in the change_timestamp_selected function the program runs the way it should...
If anyone can spot the error, please help me. Thank you.
enum btn {btnRIGHT, btnUP, btnDOWN, btnLEFT, btnSELECT, btnNONE} button;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
button = btnDOWN;
change_timestamp_selected();
delay(1000);
button = btnUP;
change_timestamp_selected();
delay(1000);
}
void change_timestamp_selected() {
switch (button) {
case btnDOWN:
Serial.println("DOWN");
bool if_commented_works = true;
break;
case btnUP:
Serial.println("UP");
break;
}
}