So, very interesting your answer, i tryed to apply making the necessary changes. But after the twentieth internet search I found this video: https://www.youtube.com/watch?v=ZsSJdGdLF-A&t=8s&ab_channel=TasteTheCode
In practice he reads the voltage that passes between the buttons and based on what is pressed Arduino reads the voltage and determines which button was pressed through a very simple IF:
void loop()
{
int value = analogRead(A0);
if (value > 800 && value < 1000) {
Serial.println("Button1");
} else if (value > 750 && value < 800) {
Serial.println("Button2");
} else if (value > 650 && value < 750) {
Serial.println("Button3");
} else if (value > 480 && value < 650) {
Serial.println("Button4");
} else if (value < 480) {
Serial.println("Button5");
}
delay(500);
}
Hope this is usefull for somebody trying do make a menu with submenu. So i created this:
while(analogRead(A1) > 700){
Serial.println("inloop");
}
delay(1000);
rifai:
btn = analogRead(A1);
Serial.println("out");
if(btn > 480 && btn < 650){ //sinistra
Serial.println("1");
imp1_1();
}else if (btn < 480){
Serial.println("2");
imp2();
}
else
goto rifai;
Yeah, i know, goto are bad... but i was lazy <3 Bye