Voltage drop after connecting stepper motors

Anyway, I changed both my motors and my steppers, redid the same thing, and now it is working fine.

I would be glad if you could just lend an eye to one of the codes I wrote.
This one is responsible for homing both the steppers. And is also using Matlab to work.

Here are the Matlab and Arduino code :

#include <AccelStepper.h>

AccelStepper StepperX(1, 7, 6); //use pin 12 and 13 for dir and step, 1 is the "external driver" mode (A4988)
AccelStepper StepperY(1, 3, 2);

char a;

void setup()
 {
   Serial.begin(9600);

   pinMode(12,INPUT);
       
   StepperY.setSpeed(50);
   StepperY.setAcceleration(50);
   
   StepperX.setSpeed(50);
   StepperX.setAcceleration(50);
   
 }

void loop()
{
  while (Serial.available() == 0)
  {
  }
  
  if (Serial.available() > 0)
  {
    a= Serial.read();
    if (a =='R')
    {
      while(digitalRead(12)!=HIGH)
      {
        StepperY.move(-1);
        StepperY.run();
      }
      while(digitalRead(13)!=HIGH)  // next putton 
      {
        StepperX.move(-1);
        StepperX.run();
      }
    }
  }
}

And

clc;
clear;

if ~isempty(instrfind) 
     fclose(instrfind);
      delete(instrfind);
end   % I find occupied port and empty them

co = serial('COM3','BaudRate', 9600);
fopen(co);
pause(0.1);
fprintf(co,'%c','R');

fclose(co);

As you may have understood by looking at the codes, upon receiving the character R (sent by Matlab), both steppers begin to move back until a logic switch is activated and change its state (low to high here).
I'm sure my Matlab code is working and is sending the R character (I confirmed it).
But when I send the character, instead of moving back until the switch is activated, it moves back for 1sec (and not step by step) and then stops.
Is it a problem with my Arduino code here?

Thanks for all your answers!