Motor won't spin. Please help

I am working on a ping pong shooting machine.
I am using x2 12v 775 dc motors.
My power supply is 18,5v 6,5A and will be used in parallel between the two motor controllers.
I am using x2 BTS7960B 43A dc motor controllers.
My problem:
When I start the motors, only motor 1 is spinning. Motor 2 is getting no output voltage from its motor controller. I already checked the pin layouts. They are the same as indicated in the code. Did I do anything wrong in the code that could cause the motor not to spin?


// Motor1
int R_EN1 = 3;
int L_EN1 = 4;
int R_PWM1 = 6;
int L_PWM1 = 7;

// Motor2
int R_EN2 = 9;
int L_EN2 = 10;
int R_PWM2 = 11;
int L_PWM2 = 12;

char input;

int Motor1Speed = 0;
int Motor2Speed = 0;

void setup() {
  // DC motor controller
  // Motor1
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);

  digitalWrite(R_EN1, HIGH);
  digitalWrite(L_EN1, HIGH);

  // Motor2
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);

  digitalWrite(R_EN2, HIGH);
  digitalWrite(L_EN2, HIGH);

  Serial.begin(38400);
}

void checkSpeed() {
  Serial.print(Motor1Speed);
  Serial.print(" : ");
  Serial.println(Motor2Speed);
}

void loop() {
  input = 'q';
  if (Serial.available() > 0) {
    input = Serial.read();
  }

  switch (input) {
    case 'b':
      Motor1Speed = 80;
      Motor2Speed = 80;
      Serial.println("Motors started");
      break;

    case 's':
      Motor1Speed = 0;
      Motor2Speed = 0;
      Serial.println("Motors stopped");
      break;

    case '1':
      if (Motor1Speed < 230) {
        Motor1Speed = Motor1Speed + 20;
        checkSpeed();
      }

      break;

    case '3':
      if (Motor2Speed < 230) {
        Motor2Speed = Motor2Speed + 20;
        checkSpeed();
      }
      break;

    case '2':
      if (Motor1Speed > 30) {
        Motor1Speed = Motor1Speed - 20;
        checkSpeed();
      }
      break;

    case '4':
      if (Motor2Speed > 30) {
        Motor2Speed = Motor2Speed - 20;
        checkSpeed();
      }
      break;
  }

  analogWrite(R_PWM1, Motor1Speed);
  analogWrite(L_PWM1, 0);
  analogWrite(R_PWM2, Motor2Speed);
  analogWrite(L_PWM2, 0);
}

Please post a wiring diagram (hand drawn is preferred) with all pins and connections clearly labeled.

Use your multimeter to check connections for continuity.

2 Likes
  • Swap the two circuits to see if motor 2 works and motor 1 does not.
1 Like

What do you want to do is there is NO SERIAL INPUT, when Serial. available() is 0? You just continue on as if something are read.

1 Like

Hi, @AGoose2B
Welcome to the forum.

Have you written your code in stages?
You should have some code that tests JUST each if the motors?
If you have not written any JUST motor code, please to test that your connections are working.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Is 80 enough to make motor 2 start?
Try 128 and see what happens.

This comment is a nonsense.

Code alone can not describe the situation when you are using an embedded processor (that is what you have). So in order to give you proper help we need a schematic.

Also you need a schematic in order to make anything, the number of people who think they don't are doomed to be for ever stuck. It surprises me how many people are ignorant of this simple fact.

I have been making circuits since 1965 and I can't do it, so what makes you think that you are "better" than me?

Here is a video to get you started:-

1 Like

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