12V DC motors randomly stopping (opening/closing a model convertible roof)

Hi there, Looking for some help.

I have a project which is moving various motors, being triggered at certain points by microswitchs.

The current issue i am running into is that sometimes the motors will just stop, even when the required conditions have been met.
I am not to sure if it is a program or wiring issue so any help will be greatly appreciated.

Please find below my program and a wiring diagram showing how i have the motors connected.

I am using ztx 653 transistors and some 5 pin relays with built in diode protection. The motors can run at about 3A 12v each.

int switchState= 0;//remote button to close
int switchState2= 0;//Hall sensor swtich
int switchState3 = 0;//Rear unlatch
int switchState4= 0;//remote button to open
int switchState5= 0;//hood is open, lock rear latch
int switchState6 = 0;//Rear is locked, stop everything.



void setup() {
  pinMode(12,OUTPUT); // Front Latch Lock
  pinMode(22,OUTPUT);//Front Latch Unlock
  pinMode(10,OUTPUT);//Hood Open
  pinMode(11, OUTPUT);//Hood Close
  pinMode(5, INPUT); //Rear Latch unlocked
  pinMode(4,INPUT);// Rear latch locked
  pinMode(7,INPUT); // Hall sensor input
  pinMode(6,INPUT);//Hood folded microswitch
  pinMode(8,OUTPUT);//Open Rear latch
  pinMode(9,OUTPUT);//Lock RearLatch
  pinMode(3,INPUT);//Open roof
  pinMode(2, INPUT);//Close roof 

  digitalWrite(10, LOW); 
  digitalWrite(22, LOW);
}

void loop()

  {
  
  unsigned long triggerMillis = 0;
    {

     static unsigned char motorState = LOW;
     static unsigned char motorState2= LOW;
     static unsigned char motorState3= LOW;
     
     
 
  
  static unsigned long motorCameOn = 0;
  static unsigned long motorCameOn2 = 0;
  static unsigned long motorCameOn3 = 0;
  
  static unsigned char buttonState = HIGH;
  static unsigned char buttonState2 = HIGH;
  static unsigned char buttonState3 = HIGH;
  
  static unsigned char lastButtonState = HIGH;
  static unsigned char lastButtonState2 = HIGH;
 static unsigned char lastButtonState3 = HIGH;

switchState = digitalRead(2);//close roof
switchState3 = digitalRead(5);//hood is unlocked ready to send powered to pin 11

 {
   
    if (switchState == HIGH && switchState3 == LOW && switchState4 == LOW) {   // open rear latch
    digitalWrite(8, HIGH);
     
    }
  else {
    digitalWrite(8, LOW);
    
    
  }
}

  
if (switchState3 == HIGH && buttonState == LOW && switchState == HIGH) {   // open rear latch
    digitalWrite(11, HIGH); }
  else {
    digitalWrite(11, LOW);
    
    
  }

 
  
  // If the Motor has been on for at least 1.8 seconds then turn it off.
  if(motorState == HIGH)
  {
    if(millis()-motorCameOn > 1800)
    {
      digitalWrite(12,LOW);
      motorState = LOW;
    }
  }

  // If the button's state has changed, then turn the Motor on IF it is not on already.
  buttonState = digitalRead(7);
  if(buttonState != lastButtonState)
  {
    lastButtonState = buttonState;
    if((buttonState == HIGH) && (motorState == LOW) && (switchState5 == LOW) && (switchState == HIGH))
    {
      digitalWrite(12,HIGH);
      motorState = HIGH;
      motorCameOn = millis();
    }
  }
     
/////////////////////////////// Opening the roof, unlock front lactch then operate roof//////////////////////////////////// 


switchState4 = digitalRead(3);// Remote button is pressed

if(switchState4 == HIGH && motorState2 == LOW && switchState6 == LOW)
{
  digitalWrite(10, HIGH);
}

else { digitalWrite(10, LOW);
}

 // If the Motor has been on for at least 5 seconds then turn it off.
  if(motorState2 == HIGH)
  {
    if(millis()-motorCameOn2 > 1800) 
    {
     
      digitalWrite(22,LOW);
      motorState2 = LOW;
    }
  }

  // If the button's state has changed, then turn the Motor on IF it is not on already.
  buttonState2 = digitalRead(3);
  if(buttonState2 != lastButtonState2)
  {
    lastButtonState2 = buttonState2;
    if((buttonState2 == HIGH) && (motorState2 == LOW) && (buttonState == HIGH))
    {
      digitalWrite(22,HIGH);
      motorState2 = HIGH;
      motorCameOn2 = millis();
    }
  }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    


    switchState5 = digitalRead(6);

    if(switchState5 == HIGH && switchState6 == LOW && switchState4 == HIGH){
      digitalWrite(9, HIGH);
      digitalWrite(10, LOW);
    }
    switchState6 = digitalRead(4);

    if (switchState5 == HIGH && switchState6 == HIGH && switchState4 == HIGH){
      digitalWrite(9, LOW);
    }
  }
  }

I don't know if it would make a difference, but the pull down resistors on the switches seem pretty low value. The usual pull down is more like 10K (1K minimum). The base resistors could be lower (minimum 180) to make sure that the transistors are fully saturated (on).

Thanks, sorted it out. replaced all the resistors to be sure.