How to fix one motor on my XIAO Esp32s3 microcontroller running continously?

Hi all, I am asking a question here as I've been stumped on how to solve an issue I've been having for a while now. I am making a quadcopter drone, and have a XIAO Esp32s3 microcontroller hooked up to a DRV 8833 motor driver. Here is the wiring diagram:


I have two drivers connected to the microcontroller, batteries are connected to each other and then hooked up to the microcontroller's battery + and - ports. All of the motors work fine with my code (which I will provide at the end), but my main issue seems to lie with one motor on one of my motor drivers. This one motor will not respond to any code issued to it, and will continuously run until my battery runs out. The driver is connected to pins D10, D9, D8, and D7. Here is the pinout:

I can't figure out why this motor is constantly running, even when I set all the motors to 0 in the code. I've tried swapping motors and swapping motor drivers but to no avail, and I've tried changing where the pins are connected, however, instead of running continuously, that motor doesn't run at all. Nothing seems to be working to fix this, is there any help I can get to get this to work properly like the other 3?
Here is my code, the first being my motorAPI.h and the second being my actual motor control code:

static void motorSetup()
{      
    ledcSetup(1 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(MotorL_A_Pin, 1 /* LEDChannel */);
    ledcWrite(1 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(2 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(MotorL_B_Pin, 2 /* LEDChannel */);
    ledcWrite(2 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(3 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(MotorR_A_Pin, 3 /* LEDChannel */);
    ledcWrite(3 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(4 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(MotorR_B_Pin, 4 /* LEDChannel */);
    ledcWrite(4 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(5 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(Motor3_A_Pin, 5 /* LEDChannel */);
    ledcWrite(5 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(6 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(Motor3_B_Pin, 6 /* LEDChannel */);
    ledcWrite(6 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(7 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(Motor4_A_Pin, 7 /* LEDChannel */);
    ledcWrite(7 /* LEDChannel */, 0); /* 0-255 */
    ledcSetup(8 /* LEDChannel */, 5000 /* freq */, 8 /* resolution */);
    ledcAttachPin(Motor4_B_Pin, 8 /* LEDChannel */);
    ledcWrite(8 /* LEDChannel */, 0); /* 0-255 */
}

static void setMotor(uint8_t la, uint8_t lb, uint8_t ra, uint8_t rb, uint8_t m3a, uint8_t m3b, uint8_t m4a, uint8_t m4b){
    ledcWrite(1 /* LEDChannel */, la); /* 0-255 */
    ledcWrite(2 /* LEDChannel */, lb); /* 0-255 */
    ledcWrite(3 /* LEDChannel */, ra); /* 0-255 */
    ledcWrite(4 /* LEDChannel */, rb); /* 0-255 */
    ledcWrite(5 /* LEDChannel */, m3a); /* 0-255 */
    ledcWrite(6 /* LEDChannel */, m3b); /* 0-255 */
    ledcWrite(7 /* LEDChannel */, m4a); /* 0-255 */
    ledcWrite(8 /* LEDChannel */, m4b); /* 0-255 */
}
#include <Arduino.h>

// Define motor driver pins
#define MotorL_A_Pin 0  // Motor A input Left
#define MotorR_A_Pin 1  // Motor A input Right
#define MotorL_B_Pin 2  // Motor B input Left
#define MotorR_B_Pin 3  // Motor B input Right
#define Motor3_A_Pin 10  // Motor A input 3
#define Motor4_A_Pin 9   // Motor A input 4
#define Motor3_B_Pin 8   // Motor B input 3
#define Motor4_B_Pin 7   // Motor B input 4


// Include the motorAPI.h file after defining the pins
#include "motorAPI.h"

void setup() {
  // Set motor driver pins as outputs
  motorSetup();
}

void loop() {
  setMotor(0, 50, 0, 50, 0, 50, 0, 50); 
  //setMotor(0, 0, 0, 0, 0, 0, 0, 0); 
}

Also here is a picture of the system in person, I know it is kind of bad but the motor that is circled in red is the one that runs continuously:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.