My problem is that in a function when you enter a conditional and it is met, it must send me to another sector of the program. But instead what it does is continue with the next conditional of the same function
here is my example code
int contador = 1; // Cuenta el nivel del menu en el que se esta
int led1 = 10; // Variable pin entrada estado alarma
int clave; // Almacena ultima clave
void setup () {
lcd.init();
lcd.backlight();
pinMode(llave, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(led1, INPUT);
}
void loop() {
if (contador == 1) {
menu_1();
accion_1();
}
if (contador == 2) {
menu_2();
accion_2();
}
}
///////////////////// Menu_1 /////////////////////
void menu_1() {
lcd.setCursor(0, 0);
lcd.print("Mostrar Variable");
lcd.setCursor(0, 1);
lcd.print(" >");
lcd.setCursor(5, 1);
lcd.print(clave);
lcd.setCursor(10, 1);
lcd.print(" H>*");
led1 = 2;
avisodes();
led1 = 2;
}
///////////////////// accion_1 /////////////////////
void accion_1() {
if (pulsacion == '*') contador = 1;
}
///////////////////////////////////////////////////
void ini2() {
lcd.setCursor(0, 0);
lcd.print(" Iniciando ... ");
lcd.setCursor(0, 1);
lcd.print(" 2 ? ? ? ? ");
if (digitalRead(led1) == 0) {
contador = 1;
} else {
ingresarpro();
c21111();
delay(250);
}
if (digitalRead(led1) == 0) {
clave = 21111;
contador = 1;
} else {
ini();
c21112();
delay(250);
}
if (digitalRead(led1) == 0) {
clave = 21112;
contador = 13;
} else {
ini();
c21113();
delay(250);
}
if (digitalRead(led1) == 0) {
clave = 21113;
contador = 1;
} else {
delay(9000);
ini3();
}
}
the problem is that when the conditional is met, for example the third "21112" and it goes to menu_1 instead of showing that saved variable, it shows the last variable of the function "21113"
I am using arduino uno, 4x3 keypad and a 16x2 lcd via I2C
Here is the complete code. Although it is very poorly optimized
Prueba_Subir.ino (52.6 KB)