Endstop for stepper

Hello, i am trouble again with this router/cnc design.

what i want now is to introduce endstops or limit end buttons to the rails of the cnc.

i came up with this code which i t doesn t seem to work out. if anybody could give me a hand i would ve in debt

The full secuence should be the next one
1 All off
2 goes to (0,0) where endstops are and waits
3 then it makes a correction to go into the wanted workarea
4 execution of the program i already have
5 it ends its secuence an goes back to 0,0
6 power off

 #define VELOCIDAD 1700
// intenta hacer los 2 loops for seguidos, total la diferencia de tiempo va a ser minima, hace 2 condicionales tambi[en.
//Y
int y[32]= 
int stepY = 3;
int dirY = 2;
int resetY = 10;
int endY_up =  12;
int endY_dw =  13;
//X
int x[32]= 
int stepX = 5;
int dirX = 6;
int resetX = 12;
int endX_lt = 10 ;
int endX_rt =  11;


int val2 = 0;
int oldval2 = 0;
int state2 = 0;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(stepY, OUTPUT); 
  pinMode(dirY, OUTPUT); 
  pinMode(resetY, OUTPUT);
  pinMode(stepX, OUTPUT); 
  pinMode(dirX, OUTPUT); 
  pinMode(resetX, OUTPUT);
  
  pinMode(endX_lt, INPUT);
  pinMode(endX_rt, INPUT);
  pinMode(endY_up, INPUT);
  pinMode(endY_dw, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  
 digitalWrite(resetY, LOW); 
 digitalWrite(resetX, LOW);  //Mientras reset este en LOW el motor permanecerá apagado y no sufrirá. El chip apagará todos los puertos y no leerá comandos.
  delay(100);
  
  if(endX_lt == HIGH && endY_up == HIGH){
    
   //falta corregir ancho y largo
   
  leidonoleido();  
  
  }
    delay(5000);
    
  digitalWrite(dirY, LOW); //ir para 0,0. arriba a la izquierda
   digitalWrite(dirX, LOW);
    for (int i = 0; i<8000; i++)       //Equivale al numero de vueltas (200 es 360º grados) o micropasos
    {  if(endX_lt == LOW){  
         digitalWrite(stepY, HIGH); 
         digitalWrite(stepY, LOW);
                          }
       if(endX_lt == LOW){ 
         digitalWrite(stepX, HIGH); // al A4988 de avanzar una vez por cada pulso de energia.  
         digitalWrite(stepX, LOW);
                         }
       delayMicroseconds(VELOCIDAD);   // Regula la velocidad, cuanto mas bajo mas velocidad.       
    }
    
}
  
  
  
  
  
  
  
  
  
void leidonoleido() {
digitalWrite(resetY, HIGH); 
digitalWrite(resetX, HIGH);  //Cuando reset se encuentre en HIGH el motor arrancará y leerá los comandos enviados.
  
   // fin de encendido
  
  //calculando pasos necesarios desde el array 
for(int u = 1; u<32; u++){
  int c = ((y[u]-y[u-1])*10); //c= cantidad de pasos en "y" que debe efectuar para ir a destino
 int d = ((x[u]-x[u-1])*10); //d= cantidad de pasos en "x" que debe efectuar para ir a destino
 
 
  if (c>0) {
    digitalWrite(dirY, LOW); // si c es mayor a 0 ir en direccion postiva
    for (int i = 0; i<c; i++)       //Equivale al numero de vueltas (200 es 360º grados) o micropasos
    {    digitalWrite(stepY, HIGH); 
         digitalWrite(stepY, LOW);
         delayMicroseconds(VELOCIDAD); }
        }
  if (d>0 ) {
    digitalWrite(dirX, LOW);
    for(int i = 0; i <d; i ++)
    {    digitalWrite(stepX, HIGH); // al A4988 de avanzar una vez por cada pulso de energia.  
         digitalWrite(stepX, LOW);
         delayMicroseconds(VELOCIDAD);  } // Regula la velocidad, cuanto mas bajo mas velocidad.       
//delay (100);
        }
        
  if (c <0) {   //si c es menor a 0 cambiamos el signo de los pasos y la direccion
    digitalWrite(dirY, HIGH);
    for (int i = 0; i<(-c); i++)       //Equivale al numero de vueltas (200 es 360º grados) o micropasos
    {  digitalWrite(stepY, HIGH);  // This LOW to HIGH change is what creates the
       digitalWrite(stepY, LOW); // al A4988 de avanzar una vez por cada pulso de energia.  
       delayMicroseconds(VELOCIDAD);  }   // Regula la velocidad, cuanto mas bajo mas velocidad.
//  delay (100);
        }
  if (d<0) {
    digitalWrite(dirX, HIGH);
    for (int i = 0; i<(-d); i++)       //Equivale al numero de vueltas (200 es 360º grados) o micropasos
    {  digitalWrite(stepX, HIGH); // This LOW to HIGH change is what creates the// al A4988 de avanzar una vez por cada pulso de energia.  
    digitalWrite(stepX, LOW);
    delayMicroseconds(VELOCIDAD);  }   // Regula la velocidad, cuanto mas bajo mas velocidad.
  }

}
}

Can't compile. The arrays y[32] and x[32] are only partially declared.

resetX (an output) and endY_up (an input) use the same pin?
resetY (an output) and endX_lt (an input) use the same pin?
I usually define names for pins in pin-number order. Makes it easy to see conflicts.

its only illustrative, i didnt want to puto the whole array of the code, in there goes a lot of information that handles steps (the number of stepx for each axis)

The reset didn t saw actually... thanks

will see how does it works with that fixed