Part

Motor driver module, L298N

Two H bridges for a robot car. Three jumpers decide how it is powered and whether ENA and ENB are pins.

See every part
  • 13 pins
  • 3 settings
  • In 6 projects
  • In 3 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Motor driver module, L298N in brief

What it is, and every setting the properties panel gives it.

The L298N module is the red board with the black heat sink under nearly every robot car: an L298 dual H bridge, a 78M05 regulator and three jumpers. It turns two DC motors either way, IN1 to IN4 setting the directions and ENA and ENB the speeds. Most of what goes wrong is a jumper, so Mokxi makes all three properties. With the ENA and ENB jumpers fitted the enables are tied high and analogWrite on them changes nothing; take a jumper off and that enable becomes a pin. With the regulator jumper fitted, the 78M05 makes the logic supply out of the motor supply, but only from about 7 V up. The L298 is a bipolar chip and keeps about 2.5 V for itself, 1.35 V on the high side and 1.2 V on the low, so a 7.4 V pack leaves a motor under 5 V. Both inputs equal brakes and the enable low coasts, here as on the bench. Current, heat and thermal shutdown are not modeled.

Family
Outputs
Pins
13
regulator
true
whether the 5 V regulator jumper is fitted (it is, out of the bag). ena_jumper,
ena_jumper
true
enb_jumper
true
whether ENA and ENB are tied high by their jumpers (they are, out of the bag).

A circuit built around it, running and explained: the Motor driver simulator.

Pins

13 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
OUT1
Motor A's screw terminal.
OUT2
Motor A's screw terminal.
12V
The motor supply, VS on the chip: 4.8 V up to 46 V.
GND
Ground, shared with the board that drives the inputs.
5V
The logic supply: an output with the regulator jumper fitted, an input without it.
ENA
Enables for motor A and motor B. High drives, low lets go.
IN1
Motor A's direction.
IN2
Motor A's direction.
IN3
Motor B's direction.
IN4
Motor B's direction.
ENB
Enables for motor A and motor B. High drives, low lets go.
OUT3
Motor B's screw terminal.
OUT4
Motor B's screw terminal.
How to use it

How to use the L298N motor driver with an Arduino

Each motor takes two direction pins and an enable: IN1 and IN2 with ENA for motor A on OUT1 and OUT2, IN3 and IN4 with ENB for motor B on OUT3 and OUT4. One input high and the other low turns the motor; swap them and it reverses; both the same brakes. For speed, pull the ENA and ENB jumpers off and drive them from PWM pins with analogWrite.

The battery goes to 12V and GND, and GND must also go to the Arduino’s GND. With the regulator jumper on, the board makes its own 5 V from a supply of about 7 V or more. The chip keeps about 2.5 V for itself, so the 7.4 V pack in the circuit here leaves each motor under 5 V.

Part pin
Board pin
ENA, IN1, IN2
Pins 5, 6, 7
IN3, IN4, ENB
Pins 8, 9, 10
12V
Battery +, 7.4 V
GND
Battery - and the Uno’s GND
OUT1, OUT2 and OUT3, OUT4
The left and right motors

An ESP32 or a Pico can drive the inputs from 3.3 V: the L298’s datasheet reads anything over 2.3 V as high. The TB6612FNG is the smaller board that keeps far less of the battery.

Arduino Uno: robot car drivelive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Motor A forward at about three quarters speed
digitalWrite(6, HIGH);   // IN1
digitalWrite(7, LOW);    // IN2
analogWrite(5, 192);     // ENA, its jumper off
How it is modeled

What is true about the Motor driver module, L298N, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

The volts the bridge keeps for itself. The L298 is a bipolar chip, and its datasheet gives 1.35 V lost in the high side and 1.2 V in the low side at 1 A, so a motor on a 12 V supply sees about 9.5 V and one on a 7.4 V pack under 5 V. That is modeled, as a source 1.35 V under the rail and a sink 1.2 V over ground, each with a little resistance on top. Braking falls out of the model: both outputs at the same place short the motor's back EMF and it stops fast, where letting go of both lets it coast. The regulator's 2 V of dropout, and the logic dying under 4.5 V, are both there. Past 46 V the outputs go dead rather than drive.

Not modeled

Current and heat. The L298 is rated 2 A a channel and the module ties its current sense pins to ground, so there is no limit here either; nothing gets hot, and there is no thermal shutdown. The advice printed on the module to pull the regulator jumper above 12 V is about the 78M05's heat, which is not modeled, so here it keeps working at 20 V. The regulator itself is a source two volts under the motor supply capped at 5 V, with no load regulation. The eight clamp diodes are on the board but not in the model: the DC motor has no inductance, so there is no kick for them to catch. The chip's switching speed, which makes PWM above about 25 kHz pointless on a real one, is not modeled.

From L298N motor driver module, in full.

Projects

See the Motor driver module, L298N in a project

6 built-in projects use it. Each opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the Motor driver module, L298N in it.

Libraries

Arduino libraries for the Motor driver module, L298N

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Motor driver module, L298N

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.