# Problem using 2 motors

I would like both the motors to spin the attached wheels forward when I push the joystick forward and vice versa. When the joystick is still, the motors should stop spinning. At the moment, when I push the joystick on x-axis and my `x` variable increases both motors spin, but when I push it in the opposite direction and `x` decreases, only motor A spins. Additionaly when I connect the arduino to the power (usb cable to my pc), motor B spins for approx 1 second and then stops.

This is the circuit I have (sorry for a lack of schematic, let's hope this wonderful drawing is enough):

The code:

``````int MotorAA = 7;
int MotorAB = 8;

int MotorBA = 11;
int MotorBB = 12;

int x = 0;

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

pinMode(MotorAA, OUTPUT);
pinMode(MotorAB, OUTPUT);

pinMode(MotorBA, OUTPUT);
pinMode(MotorBB, OUTPUT);

digitalWrite(MotorAA, LOW);
digitalWrite(MotorAB, LOW);

digitalWrite(MotorBA, LOW);
digitalWrite(MotorBB, LOW);
}

void loop() {
Move();
Serial.println(x);
}

void Move() {
if (x == 0){
return;
}

if (x > 520)
{
digitalWrite(MotorAA, HIGH);
digitalWrite(MotorAB, LOW);

digitalWrite(MotorBA, HIGH);
digitalWrite(MotorBB, LOW);
}
else if (x < 480)
{
digitalWrite(MotorAA, LOW);
digitalWrite(MotorAB, HIGH);

digitalWrite(MotorBA, LOW);
digitalWrite(MotorBB, HIGH);
}
else{
digitalWrite(MotorAA, LOW);
digitalWrite(MotorAB, LOW);

digitalWrite(MotorBA, LOW);
digitalWrite(MotorBB, LOW);
}
}
``````
• How much current are the motor pulling? Powering DC motors off the Arduino board is usually a recipe for smoke. The 5V pin is not there to power your project. You need to power the motors separately. Jun 23, 2020 at 19:27
• @Delta_G Thank you for answering. I've connected the motor driver module to the usb charger with 5V and still the same. When I connected the meter between the motor driver and the motor it showed ~0,12A. Jun 23, 2020 at 19:57
• @jsotola Good point, I'll update the post. I would like the motors to spin the attached wheels forward when I push the joystick forward and vice versa. When the joystick is still, the motors should stop spinning. Jun 23, 2020 at 20:19
• isolate the area of failure ... swap the A lines with the B lines ... does the problem stay with the motor? ... does it move ? .... switch the motors ... does the problem follow the motor? .... that kind of testing will allow you to determine where the failure is occuring Jun 23, 2020 at 20:28
• @jsotola Strangely enough, when I left only the ground and power connected to the driver, motor B acts the same. I thought that without powering the motor `a` and `b` pins on the driver, it shouldn't move. Jun 23, 2020 at 20:56