Component guide · Beginner · 5 min read
L298N motor driver

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The L298N module drives two DC motors (or one bipolar stepper) in both directions with speed control. Feed motor power of 5 to 35 V into the 12V terminal, connect IN1 to IN4 to your board for direction and ENA/ENB to PWM pins for speed. It handles about 2 A per channel but loses roughly 2 V inside the chip, so it runs warm.
Key specs at a glance
- Driver chip
- L298N dual full H-bridge (STMicroelectronics)
- Motor supply
- 5 to 35 V on the 12V terminal
- Current
- About 2 A per channel peak, 1 A continuous is comfortable
- Voltage drop
- About 1.8 to 3 V lost across the bridge
- Logic
- 5 V logic, inputs accept 3.3 V on most modules
- On-board regulator
- 78M05 gives 5 V out when the 5V-EN jumper is on (motor supply up to 12 V)
What the L298N motor driver is
The L298N is a classic dual H-bridge. Each half of the module controls one motor: two input pins set the direction and an enable pin switches the bridge on, so a PWM signal on the enable pin sets the speed. The large heatsink is there because the L298N uses bipolar transistors, which waste around 2 V as heat.
It is the most common first motor driver for two-wheel robots and line followers because it is tough, has screw terminals and needs no soldering. For battery robots where every volt counts, a MOSFET driver such as the TB6612FNG is more efficient.
L298N motor driver pinout
The pins on the L298N motor driver and what each one does.
| Pin | Function |
|---|---|
| 12V (VS) | Motor supply, 5 to 35 V |
| GND | Common ground for motor supply and controller |
| 5V | 5 V output from the on-board regulator (jumper on), or 5 V logic input (jumper off) |
| ENA / ENB | Enable for motor A / B. Jumper on = full speed; remove the jumper and apply PWM for speed |
| IN1, IN2 | Direction inputs for motor A |
| IN3, IN4 | Direction inputs for motor B |
| OUT1, OUT2 | Motor A terminals |
| OUT3, OUT4 | Motor B terminals |
- 12V (VS)
- Motor supply, 5 to 35 V
- GND
- Common ground for motor supply and controller
- 5V
- 5 V output from the on-board regulator (jumper on), or 5 V logic input (jumper off)
- ENA / ENB
- Enable for motor A / B. Jumper on = full speed; remove the jumper and apply PWM for speed
- IN1, IN2
- Direction inputs for motor A
- IN3, IN4
- Direction inputs for motor B
- OUT1, OUT2
- Motor A terminals
- OUT3, OUT4
- Motor B terminals
Wiring the L298N motor driver
Remove the ENA and ENB jumpers to control speed. Always join the module GND to the controller GND, otherwise the inputs float and the motors behave randomly. With a motor supply of 12 V or less you can leave the 5V-EN jumper on and power an Uno from the module's 5V pin.
| L298N motor driver pin | Arduino Uno | ESP32 |
|---|---|---|
| ENA | D9 (PWM) | GPIO 25 |
| IN1 | D8 | GPIO 26 |
| IN2 | D7 | GPIO 27 |
| IN3 | D5 | GPIO 14 |
| IN4 | D4 | GPIO 12 |
| ENB | D3 (PWM) | GPIO 13 |
| GND | GND | GND |
| 12V | Motor battery + | Motor battery + |
- ENA
- Arduino Uno:
- D9 (PWM)
- ESP32:
- GPIO 25
- IN1
- Arduino Uno:
- D8
- ESP32:
- GPIO 26
- IN2
- Arduino Uno:
- D7
- ESP32:
- GPIO 27
- IN3
- Arduino Uno:
- D5
- ESP32:
- GPIO 14
- IN4
- Arduino Uno:
- D4
- ESP32:
- GPIO 12
- ENB
- Arduino Uno:
- D3 (PWM)
- ESP32:
- GPIO 13
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- 12V
- Arduino Uno:
- Motor battery +
- ESP32:
- Motor battery +
Example code
Positive numbers turn the motor one way, negative the other, 0 stops it. On an ESP32 use analogWrite from core 3.x or ledcWrite for the enable pins.
const int ENA = 9, IN1 = 8, IN2 = 7;
void motorA(int speed) { // -255..255
digitalWrite(IN1, speed > 0);
digitalWrite(IN2, speed < 0);
analogWrite(ENA, abs(speed));
}
void setup() {
pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
}
void loop() {
motorA(200); delay(2000); // forward
motorA(0); delay(1000); // coast
motorA(-200); delay(2000); // reverse
motorA(0); delay(1000);
}Setup and tuning
small motors often do not start below a PWM value of about 80 to 120 because of the voltage drop. Find the lowest value that moves your robot and map your speed range from there.
add about 2 V to the motor's rated voltage. A 6 V BO motor runs at full speed with a 7.4 V (2S) pack or 8 V.
IN1 = IN2 = HIGH with ENA HIGH brakes the motor; ENA LOW lets it coast.
above 1 A continuous per channel, add airflow or switch to a MOSFET driver.
the L298N can drive a small bipolar stepper using all four inputs and the Arduino Stepper library, but it has no current limiting, so use a stepper driver for NEMA17 motors.
What you need
Shop this list4 of 5 found in our store · ₹4,47,181
L298N dual H-bridge motor driver module: the driver this guide coversL298N Dual H-Bridge Motor Driver Module₹128- Uno R3 development board: the controller used in the wiring tableFind this part
BO DC gear motor 3-12 V: a typical small robot motorBO DC Gear Motor 3–12V₹49
18650 battery holder: for a battery-powered buildBattery Holder₹45
Dupont jumper wires: for the signal connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- TB6612FNG: MOSFET driver, almost no voltage loss, 1.2 A per channel, best for small battery robots.
- DRV8833: tiny, runs from 2.7 to 10.8 V, ideal for N20 motors and single-cell builds.
- BTS7960: one motor up to tens of amps, for wheelchairs, e-bikes and large robots.
- L293D shield: plugs onto an Uno and runs four DC motors plus two servos, but only 0.6 A per motor.
Try it: Motor power torque calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- No common ground between the L298N and the controller, so the motors twitch or do not move.
- Leaving the ENA/ENB jumpers on and wondering why analogWrite does not change speed.
- Feeding more than 12 V with the 5V-EN jumper on, which overheats the on-board regulator.
- Expecting full motor voltage: a 6 V supply only gives the motor about 4 V.
Frequently asked questions
Can the L298N run on 5 V?
It will work, but the motor only sees about 3 V because of the internal drop, so small motors run slowly. Use 7 to 12 V, or a TB6612FNG for 5 V systems.
Does the L298N work with ESP32 and 3.3 V logic?
Yes on most modules: the inputs switch at about 2.3 V, so 3.3 V signals work. Power the logic side from 5 V and share GND.
How much current can it handle?
About 2 A per channel peak. For continuous use keep it at or below about 1 A per motor, or the chip overheats even with the heatsink.
Why does my L298N get hot?
It is a bipolar driver that turns about 2 V times the motor current into heat. That is normal; add airflow or use a MOSFET driver for higher currents.
Can it drive a stepper motor?
Yes, a small bipolar stepper using all four inputs. It has no current limit, so for NEMA17 motors a dedicated stepper driver is safer and quieter.
What do the 5V-EN and ENA jumpers do?
5V-EN connects the on-board 5 V regulator. ENA and ENB tie the enable pins high for full speed; remove them to use PWM speed control.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 35 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.


