ClassA Motor

How do I control a DC motor with Arduino? H-bridge, L298N vs MOSFET drivers: wiring and fixes

An Arduino pin cannot drive a motor directly. Use an H-bridge for direction and PWM for speed, compare the L298N with MOSFET driver modules, and check power and wiring.

Updated 2026-11-28

The short answer

An Arduino output pin supplies only about 20 to 40 mA, and a motor draws far more. Put an H-bridge between the Arduino and the motor, with its own supply. The H-bridge reverses the motor by changing which side of the motor gets the positive voltage, and a PWM signal on the enable pin sets the speed. The L298N is the common cheap module, but it wastes voltage and heat. A MOSFET-based driver switches with much less loss and suits motors above a few amps.

How an H-bridge works

An H-bridge has four switches arranged like the letter H, with the motor across the middle bar. Closing the top-left and bottom-right switches sends current through the motor one way. Closing the top-right and bottom-left switches reverses it. Turning on both low-side switches shorts the motor terminals and brakes it. Turning all switches off lets the motor coast. Never close the high-side and low-side switches of the same leg at the same time, because that shorts the supply.

L298N versus MOSFET drivers

  • L298N: bipolar-transistor bridge, roughly 2 to 3 V lost across the bridge at about 2 A, a maximum of about 46 V, rated around 2 A per channel, needs a heatsink, and switches slowly. Cheap and easy to find.
  • MOSFET driver: logic-level MOSFETs with a gate driver. The voltage drop is only the current times the on-resistance, so a few hundredths of an ohm loses very little power. Higher PWM frequencies are practical, and currents of 10 A or more are common on modules.
  • Check the logic level: a 3.3 V board may need a driver that accepts 3.3 V inputs, and the module's motor voltage range must include your supply.

Worked example: heat in the driver

A 12 V brushed motor draws 1.5 A at a stall. With an L298N losing about 2 V across the bridge, the driver dissipates 2 V × 1.5 A = 3 W, and the motor receives only 10 V, about 17 percent less than the supply. A MOSFET module with about 0.1 ohm total on-resistance in the current path dissipates 1.5² × 0.1 ≈ 0.2 W and leaves nearly the full 12 V at the motor. The difference is why a 3 W driver needs a heatsink and a 0.2 W driver usually does not.

Wiring steps

  • Join the grounds: Arduino GND, driver GND and the motor supply negative must share one ground.
  • Power the motor from its own supply (for example 6 to 12 V) on the driver's motor input. Never feed the motor from the Arduino 5 V pin.
  • Connect two digital pins to the direction inputs (IN1 and IN2), and one PWM-capable pin to the enable input. On the L298N, remove the enable jumper before using PWM.
  • Keep motor wires short and add a ceramic capacitor across the motor terminals to reduce brush noise. Discrete MOSFET circuits need flyback diodes for inductive spikes.

Common mistakes

  • No common ground, so the PWM signal has no reference and the driver behaves randomly.
  • Powering the motor from the Arduino 5 V pin or USB. The on-board regulator cannot supply a motor's start current.
  • Sizing the driver from the running current only. Check the stall current too: stall current is the supply voltage divided by the winding resistance.
  • Forgetting that the motor's back-EMF and switching create spikes that can damage the driver or the Arduino.

How to choose a driver

  • Motor voltage inside the driver's range, with headroom for the supply's peak voltage.
  • Continuous current at least 1.5 times the measured running current, and a peak rating above the stall current.
  • For a small brushed motor under 1 A, a single MOSFET stage or a small driver chip is enough. Above 3 A, choose a MOSFET H-bridge module with a heatsink or fan.

Full-load current, protection and cable

I = P / (√3 · U · cosφ · η)

Full-load current14.1A
Input power8.3kW
Direct-on-line starting current (6–7×)84.5–98.6A
Overload relay setting14.1A
aM fuse / D-curve breaker20A
Copper cable (PVC, 3 cores loaded)2.5mm²

Efficiency = IEC 60034-30-1 minimum for a 4-pole 50 Hz motor; power factor = typical 4-pole catalogue value. Overwrite both with nameplate data when you have it. Cable: IEC 60364-5-52 method C at 30 °C, sized for 125 % of full-load current; derate for grouping, heat and runs over ~50 m (voltage drop).

Sourcing a motor or production equipment from China? We can find and contact the right factories for you in Chinese. Ask on WhatsApp →