Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To reverse a brushed DC motor with an Arduino, use an H-bridge motor driver. The Arduino sends low-current direction and PWM signals to the driver; a separate motor power supply provides the current needed by the motor. Never connect the motor directly to an Arduino GPIO pin.

This guide shows how to wire and control one motor with a TB6612FNG, adapt the circuit for a common L298N module, select alternatives such as the DRV8833, control approximate speed with PWM, and reverse safely without overstressing the driver or mechanism.

What you need

  • Arduino Uno, Nano, or a similar 5 V logic board
  • One brushed DC motor
  • An H-bridge motor driver, preferably a TB6612FNG or DRV8833 for a small battery-powered project
  • A separate DC motor power supply or battery matched to the motor’s rated voltage
  • Jumper wires and, where appropriate, a bulk capacitor near the driver’s motor-supply input

A motor’s required current is not defined by its no-load running current alone. Startup and stall current can be several times higher. Choose a driver and supply that can tolerate the motor’s documented or measured stall current, while also allowing for heat dissipation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A motor driver is essential because Arduino GPIO pins are control outputs, not motor-power outputs. Directly connecting a motor can overload the pin, reset or damage the board, and expose it to brush noise and inductive voltage spikes. A single transistor can switch a motor in one direction, but reversing polarity requires an H-bridge or a mechanical polarity-reversing arrangement.

#1 Best Overall
Arduino Motor Shield REV3 [A000079] - Motor Control, 4 DC Motors, 2 Stepper Motors, 1.2A per Motor, Integrated Power Supply, Compatible with Arduino IDE for Robotics and Automation Projects
  • Dual H-Bridge Motor Driver: Features a dual H-bridge motor driver, enabling precise control of 4 DC motors or 2 stepper motors simultaneously, ideal for robotics, automation, and mobile projects.
  • High Current Capacity: Each channel supports up to 2A continuous current (with proper cooling), allowing you to drive higher-power motors and load-heavy applications without compromising performance.
  • Wide Voltage Range: Operates with a voltage range of 14V to 18V, making it compatible with a wide variety of motors and offering flexibility for different types of projects.
  • Built-in Overcurrent Protection: The motor shield includes thermal and overcurrent protection, ensuring reliable and safe operation by automatically shutting down in case of excessive current or overheating.
  • Full Arduino IDE Compatibility: Directly plugs into any Arduino board and is fully compatible with the Arduino IDE, allowing easy integration of motor control functions via Arduino libraries and examples for rapid prototyping.

How Arduino reverses a DC motor

A brushed DC motor reverses when the current through its armature reverses. Swapping the motor’s two wires changes the polarity. An H-bridge performs that swap electronically using four switching devices, allowing the Arduino to select either polarity without physically moving a switch. See the NYU ITP H-bridge explanation for the underlying circuit concept.

For a typical two-input H-bridge channel, the logic is:

Input 1 Input 2 Typical result
LOW LOW Stop; coast or disable, depending on the driver
HIGH LOW Direction 1
LOW HIGH Direction 2
HIGH HIGH Stop or electronic brake, depending on the driver

“Clockwise” and “counterclockwise” are not universal electrical labels. They depend on which side of the motor you view and how its two wires are connected. If your motor runs opposite to the label in your project, swap the motor wires or invert the direction condition in software.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing a motor driver

Driver Good fit Main trade-off
TB6612FNG Small robots and efficient battery-powered projects Current and thermal limits are relatively modest
DRV8833 Small, low-voltage motors Lower motor-voltage range and carrier-specific current limits
L298N Legacy tutorials, kits, and simple prototypes Large voltage drop, lower efficiency, and more heat
Arduino Motor Shield Rev3 Uno-style shield projects needing two channels and current sensing L298-based losses and heat
Discrete MOSFET H-bridge Custom high-current products Requires careful gate drive, layout, protection, and thermal design

For most new small-motor builds, a MOSFET-based TB6612FNG or DRV8833 is a better default than an L298N. The L298N remains usable when compatibility with an existing kit matters, but its bipolar transistor outputs waste more voltage as heat.

For example, Pololu specifies its TB6612FNG carrier for a recommended 4.5–13.5 V motor supply, 2.7–5.5 V logic, 1 A continuous current per channel, and 3 A peak current per channel. Those figures apply to that carrier under its specified thermal and transient conditions; they are not universal ratings for every TB6612FNG breakout.

TI lists the DRV8833 with a 2.7–10.8 V operating range, two full bridges, PWM control, current regulation, and overcurrent, short-circuit, undervoltage, and overtemperature protection. The particular breakout board still determines its practical current and cooling limits.

Rank #2
ELEGOO Mega 2560 R3 Project The Most Complete Starter Kit with Tutorial
  • 35+ Guided Electronics Projects: Progress from LEDs and buttons to RFID access, real-time clocks, motion and distance sensing, environmental monitoring, motor control and interactive displays for STEM learning, coding clubs and maker projects
  • More I/O and Memory for Larger Builds: The MEGA 2560 R3 provides 54 digital I/O pins, including 15 PWM outputs, 16 analog inputs, 4 hardware serial ports and 256 KB flash for projects that combine more sensors, controls and displays
  • 200+ Components for Prototyping: Includes LCD1602, RC522 RFID, RTC, DHT11, HC-SR501 PIR, ultrasonic and water-level sensors, GY-521, MAX7219, keypad, joystick, rotary encoder, relay, SG90 servo, stepper motor, DC motor, breadboard and more
  • Learn, Modify and Create: Follow 35+ guided lessons with example code, then adjust sensor thresholds, timing, display text, motor behavior and control logic to turn structured exercises into access systems, monitors, alarms and interactive projects
  • Organized for Repeatable Learning: Pre-soldered modules, a solderless breadboard, storage case and small-parts box reduce setup time and keep sensors, LEDs, ICs, wires and other components easy to find between projects

Recommended TB6612FNG wiring

Use channel A for one motor. A suitable Arduino Uno-class pin assignment is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
TB6612FNG pin Connection
VCC Arduino logic supply, commonly 5 V on an Uno; verify the board’s logic range
VM or VMOT Positive terminal of the separate motor supply
GND Arduino GND and motor-supply negative
AIN1 Arduino D7
AIN2 Arduino D8
PWMA Arduino D5, a PWM-capable pin on an Uno
STBY Arduino D4, driven HIGH to enable the driver
AO1 and AO2 The two motor terminals
Arduino D7  -> AIN1
Arduino D8  -> AIN2
Arduino D5  -> PWMA
Arduino D4  -> STBY
Arduino GND -> driver GND
External +  -> VM/VMOT
External -  -> driver GND
Motor       -> AO1 and AO2

The Arduino and motor supply may be separate, but their grounds normally need a common reference. Connect Arduino GND to driver GND and motor-supply negative unless your design intentionally uses isolated logic. Arduino’s power-supply guidance recommends external power for high-current components such as motors.

Do not power the motor from the Arduino 5 V pin or USB connection. The motor supply voltage must match the motor’s rating, and its current capacity must account for startup and stall conditions.

Working Arduino code for the TB6612FNG

const byte AIN1 = 7;
const byte AIN2 = 8;
const byte PWMA = 5;   // PWM-capable pin on an Arduino Uno-class board
const byte STBY = 4;

void setup() {
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(PWMA, OUTPUT);
  pinMode(STBY, OUTPUT);

  digitalWrite(STBY, HIGH);  // enable the driver
  stopMotor();
}

void loop() {
  setMotor(180, true);   // Direction 1, approximately 71% PWM
  delay(2000);

  stopMotor();
  delay(500);

  setMotor(180, false);  // Direction 2
  delay(2000);

  stopMotor();
  delay(1000);
}

void setMotor(byte speed, bool direction1) {
  digitalWrite(STBY, HIGH);

  if (direction1) {
    digitalWrite(AIN1, HIGH);
    digitalWrite(AIN2, LOW);
  } else {
    digitalWrite(AIN1, LOW);
    digitalWrite(AIN2, HIGH);
  }

  analogWrite(PWMA, speed);  // 0-255 on typical 8-bit Arduino PWM
}

void stopMotor() {
  analogWrite(PWMA, 0);
  digitalWrite(AIN1, LOW);
  digitalWrite(AIN2, LOW);
}

On boards using 8-bit Arduino PWM, analogWrite(PWMA, 0) commands zero duty cycle and analogWrite(PWMA, 255) commands approximately full duty cycle. PWM changes the average voltage and power applied to the motor; it does not precisely regulate RPM. Actual speed changes with load, supply voltage, friction, motor characteristics, and battery state.

The TB6612FNG’s STBY input must be HIGH for operation on common carrier boards. Pin names and exact truth-table behavior should still be checked against the board or IC documentation. Pololu’s TB6612FNG carrier documentation describes its standby, PWM, and channel functions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Coast, brake, stop, and standby

These terms describe different electrical actions:

  • Coast: the motor outputs are disconnected or high impedance, so the motor slows naturally.
  • Brake: both motor terminals are driven to the same electrical state, producing dynamic braking when supported by the driver.
  • Stop: an informal term that may mean zero PWM, coast, or brake.
  • Standby or disable: the driver’s output stage is disabled.

Do not assume that LOW/LOW or HIGH/HIGH has the same result on every driver. Check the specific truth table. TB6612FNG documentation and the SparkFun hookup guide distinguish the driver’s operating and braking modes.

Rank #3
REXQualis Super Starter Kit Based on Arduino UNO R3 with Tutorial and Controller Board Compatible with Arduino IDE
  • The most economical kit comes with everything compatible with Arduino to starting programming for beginners .
  • This is the upgraded starter kits come with a 9V 1A Power Adapter (At least $5.99 on amazon) to replace a 9V Battery , and the Lcd1602 module come with pin header(not need to be soldered by yourself).
  • Include High Quality Base Board base on Arduino UNO R3 compatible with Arduino IED and Sensors, Servo, Motor, ULN2003 driver board, lcds, etc.
  • Free PDF Tutorial and Datasheet are available to download from our official website or you can contact our customer service.
  • All of the Components and Integrated Circuits are individually packaged and labeled, and packing in a plastic box which is bigger enough for you.

Reverse safely

Instantly reversing a fast motor or a high-inertia load can produce a large current surge and mechanical shock. At minimum, remove PWM briefly before applying the opposite direction:

void reverseSafely(byte newSpeed, bool newDirection) {
  analogWrite(PWMA, 0);
  delay(100);  // increase for heavier or faster loads
  setMotor(newSpeed, newDirection);
}

The 100 ms delay is only an example, not a universal value. For a heavy load, ramp the PWM down, coast or brake if appropriate, wait for the motor to slow, then ramp PWM up in the new direction. The correct timing depends on inertia, gearing, load, and the driver’s braking behavior.

Using a common L298N module

Many red L298N modules expose terminals or pins labelled ENA, IN1, IN2, OUT1, OUT2, GND, and +12V or VS. Typical wiring is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Arduino PWM pin   -> ENA
Arduino digital   -> IN1
Arduino digital   -> IN2
Motor             -> OUT1 and OUT2
External motor +  -> +12V / VS
External motor -  -> GND
Arduino GND       -> module GND

To control speed with PWM, remove the ENA jumper on modules that use that jumper to permanently enable the channel. With the jumper installed, the channel may remain enabled continuously. Module layouts, jumpers, onboard regulators, diode arrangements, and labels vary by manufacturer, so inspect the exact board before applying power.

const byte ENA = 5;
const byte IN1 = 7;
const byte IN2 = 8;

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  stopMotor();
}

void loop() {
  setMotor(180, true);
  delay(2000);

  stopMotor();
  delay(500);

  setMotor(180, false);
  delay(2000);

  stopMotor();
  delay(1000);
}

void setMotor(byte speed, bool forward) {
  if (forward) {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
  } else {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
  }

  analogWrite(ENA, speed);
}

void stopMotor() {
  analogWrite(ENA, 0);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
}

The “12 V” marking commonly identifies the motor-supply terminal; it does not necessarily mean that every motor or the module itself must operate at 12 V. The L298N’s relatively high output voltage drop can leave a low-voltage motor weak and turn more input power into heat. Do not assume its onboard 5 V regulator is suitable for powering an Arduino and other peripherals.

The official Arduino Motor Shield Rev3 is also L298-based, but its pin mapping, protection, connectors, and specifications should not be treated as identical to a generic L298N module.

Rank #4
ELEGOO 5 Sets 28BYJ-48 ULN2003 5V Stepper Motor with ULN2003 Driver Board
  • BUILD FIVE LOW-SPEED MOTION PROJECTS: Create clocks, gauges, rotating displays, feeder gates, vents and small robot mechanisms; five matched motor-and-driver sets support classroom builds, maker prototypes and spare replacements
  • 5 V UNIPOLAR GEARED STEPPER MOTORS: Each 28BYJ-48 uses a 5-wire, 4-phase design with nominal 1:64 reduction for controlled low-speed movement in light-load positioning projects
  • ULN2003 DRIVER BOARDS SIMPLIFY CONTROL: Connect control signals to IN1-IN4, power the motor through the driver board and use four onboard LEDs to view the active coil sequence during setup and testing
  • SET UP FOR SMOOTHER ROTATION: Use a regulated 5 V supply with sufficient current, connect controller and motor-supply grounds together, verify the motor plug and IN1-IN4 sequence, and reduce speed if the shaft buzzes or vibrates
  • FIVE COMPLETE MOTOR-DRIVER SETS: Includes 5 × 28BYJ-48 stepper motors, 5 × ULN2003 driver boards and 10 × female-to-male jumper wires for multiple prototypes and replacement builds

Power, wiring, and protection

  • Use a separate battery or DC supply for the motor.
  • Match the supply voltage to the motor’s rated voltage and stay within the driver’s motor-voltage range.
  • Choose a supply that can handle startup and stall current. A supply with a higher current rating does not force that current into the motor; the load draws what it requires, subject to voltage and protection limits.
  • Keep motor-current wiring short and appropriately thick.
  • Add bulk capacitance close to the driver’s motor-supply input if the board does not already provide adequate capacitance.
  • A small suitable ceramic capacitor directly across the motor terminals can reduce brush noise.
  • Keep motor wires away from analog, radio, and encoder wiring.
  • Use a fuse or resettable fuse in battery-powered builds where a short or stalled motor could overheat the wiring.

Motor windings are inductive. When driver switches open, the stored magnetic energy needs a safe clamp path. Modern carrier boards may include flyback or kickback protection, but a bare motor-driver IC or generic module should never be assumed to have the same protection. For example, Adafruit documents internal kickback diodes and separate logic and motor supplies on its TB6612 breakout; its stated current limit applies to that breakout, not every TB6612FNG board.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before testing, secure the motor and keep fingers, loose clothing, and tools away from moving parts. A stalled motor is often the worst thermal condition. For initial wiring checks, disconnect the motor or use a current-limited bench supply.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Testing procedure

  1. Verify the motor’s rated voltage and stall current from its datasheet or a careful measurement.
  2. With the motor disconnected, check VCC, VM, GND, and the driver’s enable or standby wiring.
  3. Confirm that Arduino ground and driver ground are connected.
  4. Upload the sketch and confirm that the logic pins change as expected with a multimeter or oscilloscope.
  5. Connect the motor and begin with a low PWM value.
  6. Confirm direction, then increase the duty cycle gradually while monitoring driver and motor temperature.
  7. Test reversal only after the motor has stopped or slowed substantially.
  8. Test the real mechanical load gradually rather than starting with a stalled or jammed mechanism.

Troubleshooting

The motor does not move

  1. Check that the motor supply is connected to the driver’s motor-voltage input.
  2. Confirm a common ground.
  3. For a TB6612FNG, confirm that STBY is HIGH.
  4. For an L298N, confirm that ENA is enabled and remove its jumper when using PWM.
  5. Check the motor output pair and all terminal connections.
  6. Verify the supply voltage and current capability.
  7. Check for a mechanical stall or a driver thermal shutdown.

The motor runs only one way

Check both direction inputs, the GPIO assignments, the code branch that changes direction, and the driver’s channel. A damaged input, incorrect L298N jumper arrangement, or supply collapse during reversal can also cause this symptom. Do not short driver outputs together. Test signals with a meter or oscilloscope, or test with a safe indicator circuit appropriate to the board.

The Arduino resets when the motor starts

The motor may be drawing from the Arduino regulator or USB supply, pulling down a shared supply, injecting brush noise, or causing a poor ground connection. Use a separate motor supply, connect grounds correctly, improve the power wiring, add suitable decoupling near the driver, and suppress motor noise. A PP3 rectangular 9 V battery commonly performs poorly because its internal resistance causes severe voltage sag under motor load.

The motor is weak or slow

Possible causes include the L298N’s voltage drop, an inadequate battery, low PWM duty cycle, a supply voltage below the motor’s rating, excessive mechanical load, thermal limiting, or operation near stall. Do not raise the voltage above the motor or driver rating to compensate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PWM does not change speed

Confirm that the PWM or enable input is connected to a PWM-capable pin for the selected Arduino board, that the L298N’s enable jumper is removed, that TB6612FNG standby is HIGH, and that the code calls analogWrite() on the correct pin. PWM is open-loop drive, so a motor may show little speed change near a load or supply limit. PWM frequency, resolution, and pin availability vary across Arduino boards.

Best Value
ELEGOO UNO R3 Project Super Starter Kit with PDF Tutorial for Beginners
  • TURN CODE INTO REAL-WORLD RESULTS — Follow 22+ guided lessons to make LEDs blink, read temperature and distance, move servo and stepper motors, control an LCD and respond to joystick or IR input; ideal for a family weekend build, homeschool unit, coding club or STEM classroom
  • MORE PROJECT VARIETY IN ONE ORGANIZED KIT — Includes the UNO R3 controller, LCD1602 with pre-soldered header, breadboard power module, ultrasonic and DHT11 sensors, joystick, IR receiver and remote, SG90 servo, stepper motor, relay, DC motor, fan blade, displays, LEDs, buttons, resistors and jumper wires
  • START WITHOUT SOLDERING — Plug-in modules, a solderless breadboard and the pre-soldered LCD help beginners focus on wiring, code and testing; the illustrated component list makes it easier to find each part and move from one lesson to the next
  • LEARN THE LOGIC, THEN CREATE YOUR OWN — Use Arduino IDE and the included example code to understand digital input and output, analog sensing, timing, motor control and display functions, then change thresholds, speeds and sequences for alarms, environmental monitors, reaction games and motion projects
  • CLEAR SETUP SUPPORT FOR FIRST-TIME BUILDERS — Download the latest tutorial and code, select the UNO board and correct computer port, check component polarity and breadboard rows, and keep power-module input at 9V or below; younger learners should work with an experienced adult

The direction label appears backwards

Swap the two motor wires or invert the software’s direction condition. This is normal because direction names depend on viewing orientation and motor-wire polarity.

When a relay is better—and when it is not

A relay arrangement can reverse polarity for a slow, simple on/off actuator and may handle some current levels. It is a poor choice for frequent reversals or speed control because contacts wear, switching is slow, arcing is possible, and PWM is impractical. An H-bridge is the normal choice for electronically controlled brushed DC motors.

This method is for brushed DC motors. Steppers require phase sequencing through a stepper driver, while brushless motors require a brushless controller or ESC.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Buying guidance

Choose by electrical requirements rather than by the module’s advertised peak number:

  1. Motor nominal voltage.
  2. Documented or measured stall current.
  3. Required continuous and startup current.
  4. Number of motors and channels.
  5. Logic-voltage compatibility.
  6. Required braking, current sensing, or current limiting.
  7. Thermal conditions and enclosure airflow.
  8. Battery efficiency and acceptable voltage drop.

A TB6612FNG carrier or breakout is the best general choice for many small battery-powered projects. A DRV8833 is attractive for lower-voltage motors. An L298N is acceptable for legacy compatibility and basic experiments, but usually wastes more energy. The Arduino Motor Shield Rev3 suits Uno-style shield stacks and provides two channels and current-sensing features, while a custom MOSFET bridge is appropriate only when the project justifies the additional design complexity.

As examples of vendor positioning, Pololu lists its TB6612FNG carrier at a price observed on August 18, 2026, and Adafruit lists its TB6612 breakout at a separate price observed on the same date. Shipping, taxes, stock, regional availability, and board revisions can change, so treat those pages as current product references rather than permanent prices. The relevant official pages are Pololu’s carrier page and Adafruit’s breakout page.

Conclusion

The essential rule is simple: the Arduino controls the H-bridge; the external power supply powers the motor. Connect the motor to the driver’s output pair, share the logic ground, use two direction inputs to select polarity, and use PWM on the driver’s enable input for approximate speed control. Size the driver for stall current, account for heat and voltage drop, and slow or stop the motor before reversing under load.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.