Why does not the keypad code break the cycle?

Thanks for reading my question. What happens is that I have a vibrating table that uses step-by-step motors with a keypad but, for the motor to turn I use the for cycle but what I want when I press 1 button starts in one direction (which is what it does) but after that I want that if I press another button my table goes in another direction since my table is of two directions but what happens is that for example if the button 1 is for the address "x" and the button 2 is for the address in "and" I press the button 1 and all good but, when I press the button 2 it does not change my direction but I have to wait for the cycle for and that I do not want, I want it when I press the button 2 Change address automatically. Thank you a lot

(the file called "Mark 7" contains the complete code thank you very much)

CODE

void loop(){
tecla = teclado.getKey();

if (tecla != NO_KEY ){ //== para condicion si es igual y != si es diferente
//numero = tecla - 48;

switch(tecla){
case '1':
for (int i = 0; i<a; i++){ horario1();
for (int i = 0; i<totalpasos1; i++){m1();} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
//—————————Cambio de sentido de giro——————————–
antihorario1();
for (int i = 0; i<totalpasos1; i++){m11(); }} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
digitalWrite(reset1, LOW);
break;

case '2':
for (int i = 0; i<a; i++){ horario2();
for (int i = 0; i<totalpasos2; i++){m2();} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
//—————————Cambio de sentido de giro——————————–----------------------------------------------------------------------------
antihorario2(); //mandamos direccion al servo
for (int i = 0; i<totalpasos2; i++){m22();}} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
digitalWrite(reset1, LOW);
break;

case 'F':
for (int i = 0; i<a; i++){ //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
horario1();
horario2();
for (int i = 0; i<totalpasos1; i++){ //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
m1() ;
m2() ;}
//—————————Cambio de sentido de giro——————————–---------------------------------------------------------------------------
antihorario1();
antihorario2();
for (int i = 0; i<totalpasos1; i++){ //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
m11() ;
m22() ;}}
digitalWrite(reset1, LOW);
break;

case 'A':
horario1();
for (int i = 0; i<totalpasos1; i++){m1();} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
digitalWrite(reset1, LOW);
break;

case 'B':
antihorario1();
for (int i = 0; i<totalpasos1; i++){m11();} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
digitalWrite(reset1, LOW);
break;

case 'C':
horario2();
for (int i = 0; i<totalpasos1; i++){m2();} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
digitalWrite(reset2, LOW);
break;

case 'D':
antihorario2();
for (int i = 0; i<totalpasos1; i++) {m22();} //Equivale al numero de vueltas (200 pasos son 360º grados de servo )
digitalWrite(reset2, LOW);
break;

case '4' :
for (int i=0; i<a; i++){
horario1();
for (int i = 0; i<totalpasos3; i++){m3();}//Equivale al numero de vueltas (200 pasos son 360º grados de servo )
antihorario1();
for (int i = 0; i<totalpasos3; i++){m33();}}
digitalWrite(reset1, LOW);
break;

case '5' :
for (int i=0; i<a; i++){
horario2();
for (int i = 0; i<totalpasos3; i++){m4();}//Equivale al numero de vueltas (200 pasos son 360º grados de servo )
antihorario2();
for (int i = 0; i<totalpasos3; i++){m44();}}
digitalWrite(reset1, LOW);
break;

}}}

Mark7.txt (8.39 KB)

   break;

   
   

    }}}

Your code is a horrid mess. NOTHING follows a } on the same line. Put EVERY { on a line BY ITSELF. Put EVERY } on a line BY ITSELF. Use Tools + Auto Format. Post your code IN CODE TAGS if you expect anyone to read it.