PinLab › Components › L298N dual H-bridge
OUT1/2OUT3/4 ENA IN1 IN2 IN3 IN4 ENB 12V GND 5V

L298N dual H-bridge

DC motor driver

Lets the ESP32 control two DC motors (direction and speed) that need far more current than one pin can give.

Open the course →

How it works

An H-bridge is 4 transistors around the motor. With IN1/IN2 you choose which two are on → current flows left-right or right-left → the motor turns forward or backward. PWM on ENA → speed. The module is powered with 7–12 V for the motors, and an internal regulator gives 5 V (it can also power the ESP32 via VIN if you leave the jumper on).

Pins and wiring

PinWhat it isWhere it connects / why
12V (VCC)Motor power6 – 12 V from a battery/adapter.
GNDGroundMust be common with the ESP32 GND.
5V5 V output (with jumper) / inputCan → VIN on the ESP32 if the input is 7–12 V.
ENA / ENBEnable (speed) for motor A / B→ PWM GPIO. With the jumper = always full speed.
IN1, IN2Direction motor A→ 2 GPIO. 10 = forward, 01 = backward, 00/11 = stop.
IN3, IN4Direction motor B→ 2 GPIO.
OUT1, OUT2Motor AThe two motor terminals.
OUT3, OUT4Motor BThe two motor terminals.

Specifications

Motor voltage5 – 35 V
Current2 A per channel (continuous)
Voltage drop~2 V (the motor gets less)
Logic input3.3 V OK

Tips and typical mistakes