DC motor runs only one direction with an H-bridge driver

One direction working means the driver and motor are alive, so the fault is in one direction signal. Check the two input pins and the code that sets them.

What the message means

An H-bridge needs one input high and the other low to drive the motor. Swapping them reverses it. If one combination fails, one input never changes.

Fix it in this order

  1. Test each input pin with a simple sketch that sets one high and one low, then swaps them.
  2. Check the wire and solder on both direction inputs.
  3. Make sure PWM is applied to the enable pin, or to the correct input, as your driver expects.
  4. Check the pin number in code matches the wire. Swapped numbers make a direction dead.
  5. Confirm the pin supports output. On an ESP32, GPIO 34 to 39 are input only.
  6. Try the other channel. If it works there, the first channel may be damaged.

Why it happens

If a motor runs only one way, one direction input is stuck or the code never sets it. With an H-bridge such as the L298N or TB6612FNG the direction is set by two input pins: one high and one low in one direction, reversed for the other.

Test with a simple sketch that sets IN1 high and IN2 low, waits, then swaps them. Check each input with a multimeter or an LED, and look for a loose wire or a damaged driver channel.

If you see this, do this

You seeDo this
Forward works, reverse does notThe second input pin has no signal.
Both directions fail on one channelCheck that channel enable and supply.

L298N motor not spinning, L298N vs TB6612FNG.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

Why this happens

An H-bridge connects the motor to the supply through two high-side switches and two low-side switches. To run forward, one diagonal pair is switched on; to reverse, the other diagonal pair. The control inputs select which pair. If the motor works in one direction, the supply, the motor and one diagonal pair are all fine, so the fault is limited to the other input path.

That path can fail in only a few places: the control signal never reaches the driver (a broken wire, a wrong pin number, a pin that cannot output), the code never sets that pin, or the second half of the bridge inside the driver is damaged.

How to confirm the cause

  • Measure the voltage at each direction input with a multimeter while the code runs. One input should read high and the other low; swapped when you reverse. An input that never moves is a wiring or code fault.
  • Move the wire from the working input to the dead input’s pin. If the motor now runs the other way, the original pin or wire was bad.
  • Swap the two motor wires. If the dead direction stays on the same input, the driver is the problem, not the motor.
  • Try the second channel of the driver. If it reverses properly, the first channel is damaged.
  • Print the pin numbers in setup() and compare them with the wiring.

Worked example

A test that runs the motor one way, stops it, then runs it the other way, with an L298N. ENA takes PWM; IN1 and IN2 set direction:

const int ENA = 9, IN1 = 7, IN2 = 8;

void drive(int speed) {              // -255 .. 255
  digitalWrite(IN1, speed >= 0);
  digitalWrite(IN2, speed < 0);
  analogWrite(ENA, abs(speed));
}

void setup() {
  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
}
void loop() {
  drive(180); delay(2000); drive(0); delay(500);
  drive(-180); delay(2000); drive(0); delay(500);
}

Common mistakes

  • Using analogWrite on a pin that has no PWM.
  • Leaving the enable jumper on while also connecting a PWM wire to the same pin.
  • Using GPIO 34 to 39 as outputs on an ESP32; these are input only.
  • Using pin 0 or 1 on an Arduino Uno while the Serial port is also in use.
  • Putting the motor ground and the controller ground on separate rails.

If this did not fix it

  • Low supply voltage on the driver, which can make one direction fail under load.
  • A stalled or worn motor that works lightly one way and sticks the other way because of a mechanical fault.
  • A damaged driver channel after a stall or a short; try a different driver module.