#define PIN_R 3
#define PIN_L 2
unsigned short int lastMenu = 0;
String arrayMenu[] = {"MENU 1","MENU 2","MENU 3","MENU 4"};
bool test1 = true;
bool test2 = true;
void setup()
{
Serial.begin(9600);
pinMode(PIN_R, INPUT);
digitalWrite(PIN_R, HIGH);
pinMode(PIN_L, INPUT);
digitalWrite(PIN_L, HIGH);
}
void loop()
{
if(digitalRead(PIN_R) == LOW && test1 == true)
{
if(lastMenu < 3)
lastMenu++;
else
lastMenu = 0;
Serial.println(arrayMenu[lastMenu]);
test1 = false;
}
else if(digitalRead(PIN_R) != LOW && test1 != true)
{
test1 = !false;
}
if(digitalRead(PIN_L) == LOW && test2 == true)
{
if(lastMenu > 0)
lastMenu--;
else
lastMenu = 3;
// lastMenu >= 0 ? lastMenu-- : lastMemu=3;
Serial.println(arrayMenu[lastMenu]);
test2 = false;
}
else if(digitalRead(PIN_L) == HIGH && test2 == false)
{
test2 = true;
}
}