L298N Dual Motor Driver

The L298N drives two DC motors in both directions: two direction inputs per motor and an enable pin for speed.

Actuators6 blocksMicroPythonC++
L298N Dual Motor Driver Module

At a glance

Pins and properties exactly as the circuit editor and simulator define this part. The text below explains how to use them.

Pinout

Pinout of the L298N Dual Motor Driver Module, drawn as in the circuit editor. Select a label to see that pin in the table below.

Pins

Pins of this part
PinLabelType
OUT1OUT1Power in
OUT2OUT2Power in
OUT3OUT3Power in
OUT4OUT4Power in
VCC_M12VPower in
GNDGNDGround
VCC_5V5VPower in
ENAENASignal in
IN1IN1Signal in
IN2IN2Signal in
IN3IN3Signal in
IN4IN4Signal in
ENBENBSignal in

The L298N module is a dual H-bridge. A board pin cannot power a motor directly, so the driver sits between them: the board only sends small control signals, and the module switches the motor power. One module drives two DC motors, each in both directions.

Pins

GroupPinsWhat they do
Motor outputsOUT1, OUT2 / OUT3, OUT4Motor A on OUT1 and OUT2, motor B on OUT3 and OUT4
Motor supply12V (VCC_M) and GNDThe power the motors use (use your battery, not the board's pin)
Logic supply5VLogic power of the module
ControlIN1, IN2 / IN3, IN4Direction of motor A / motor B
EnableENA / ENBSwitches a motor on; a PWM signal here sets its speed

How to drive a motor

For motor A (motor B works the same with IN3, IN4 and ENB):

IN1IN2Result
HIGHLOWForward
LOWHIGHReverse
LOWLOWStops freely
HIGHHIGHBrakes

A PWM signal on ENA sets the speed (a duty cycle of 50 % is about half the speed).

Blocks

Drawing the blocks…

Troubleshooting

  • The motor does not turn: the ground of the motor supply and the board must be connected together, and the enable pin must be HIGH or PWM.
  • The motor turns the wrong way: swap IN1 and IN2 (or the motor wires).
  • The board resets when the motor starts: power the motors from their own battery, not from the board.
L298N Dual Motor Driver — OMS Parts