Blog

L298N Dual H-Bridge Motor Driver Module – Complete Guide

Dual H-Bridge Motor Driver

L298N Dual H-Bridge Motor Driver Module

Drive Two DC Motors or One Stepper from Logic-Level Signals

A microcontroller GPIO pin can only source a few tens of milliamps - nowhere near enough to spin a DC motor - and it has no built-in way to reverse a motor's direction either. An H-bridge circuit solves both problems at once: four switching transistors are arranged so that opposite diagonal pairs can be turned on together, letting current flow through the motor in either direction depending on which pair is active, while a separate PWM-driven enable pin controls how much of the time that current flows, which is what sets speed. The L298N chip at the heart of this module packs two complete H-bridges into a single IC, so one board can independently control direction and speed for two separate DC motors, or be rewired to drive a single 4-wire bipolar stepper motor instead. The breakout board built around it adds terminal blocks for easy wiring, protective flyback diodes to absorb the voltage spikes motors generate when switched off, and an onboard 5V regulator that - within its voltage limits - can power your logic-side electronics from the same supply as the motors, avoiding a second power source.

2 DC Motors or 1 Stepper
Drives
2A per channel
Max Current
5V – 35V
Motor Supply

Key features

Dual H-Bridge

Independently drives two DC motors, each with its own direction and speed control.

Stepper Motor Capable

Can be rewired to drive a single 4-wire bipolar stepper motor instead.

PWM Speed Control

Dedicated ENA/ENB enable pins accept a PWM signal for variable motor speed.

Onboard 5V Regulator

Can power logic-side electronics from the same supply as the motors.

Built-In Flyback Diodes

Protects the driver IC from voltage spikes caused by motor back-EMF.

Screw Terminal Connections

Solid, solder-free wiring for both motor leads and power input.

Technical specifications

Logic Supply 5V (onboard regulator or external)
Motor Supply (VMS) 5V – 35V DC
Max Current per Channel 2A peak (~1A continuous recommended)
Driver IC L298N dual full-bridge
Control Inputs IN1–IN4 (direction) + ENA/ENB (PWM speed)
Motors Supported 2x DC brushed, or 1x 4-wire bipolar stepper
Heat Dissipation Onboard heatsink on the L298N package
Protection Built-in flyback diodes for inductive kickback
Package Breakout board with screw terminals

Pinout

PinFunction
IN1–IN4 Direction control inputs for motor A / motor B
ENA / ENB PWM speed enable for motor A / motor B
OUT1–OUT4 Motor A / motor B output leads
12V / GND / 5V Motor supply in, common ground, regulated 5V out

Applications

Robot chassis wheel drivers RC car direction and speed control Basic CNC/3D-printer axis stepper driving Conveyor belt direction control Automated curtain and blind motors Pan-tilt or turret DC motor rigs

What's in the box

1x L298N motor driver module

Downloads

Datasheet (PDF) Arduino Dual-Motor Example Sketch
🔌
Pin Connections
1 Table
Pin Connections Table 1
BoardSensor PinConnection
L298NIN1/IN2/ENAboard digital / board digital / board PWM pin (repeat IN3/IN4/ENB for the second motor)
📟
L298N Motor Driver Module - 2A Dual Channel
7 Examples • C/C++ | Boards: Arduino Uno, Arduino Nano, Arduino Mega, ESP32, ESP8266, STM32, Raspberry Pi Pico
L298N Motor Driver Module - 2A Dual Channel - Arduino Uno
L298N Motor Driver Module - 2A Dual Channel - Arduino Nano
L298N Motor Driver Module - 2A Dual Channel - Arduino Mega
L298N Motor Driver Module - 2A Dual Channel - ESP32
L298N Motor Driver Module - 2A Dual Channel - ESP8266
L298N Motor Driver Module - 2A Dual Channel - STM32
L298N Motor Driver Module - 2A Dual Channel - Raspberry Pi Pico
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_arduino_uno.inoArduino Uno
867 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=8, IN2=9, ENA(PWM speed)=10 on Arduino Uno. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 8
7#define IN2 9
8#define ENA 10
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_arduino_nano.inoArduino Nano
868 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=8, IN2=9, ENA(PWM speed)=10 on Arduino Nano. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 8
7#define IN2 9
8#define ENA 10
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_arduino_mega.inoArduino Mega
868 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=8, IN2=9, ENA(PWM speed)=10 on Arduino Mega. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 8
7#define IN2 9
8#define ENA 10
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_esp32.inoESP32
865 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=26, IN2=27, ENA(PWM speed)=25 on ESP32. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 26
7#define IN2 27
8#define ENA 25
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_esp8266.inoESP8266
867 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=D5, IN2=D6, ENA(PWM speed)=D7 on ESP8266. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 D5
7#define IN2 D6
8#define ENA D7
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_stm32.inoSTM32
871 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=PB0, IN2=PB1, ENA(PWM speed)=PA8 on STM32. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 PB0
7#define IN2 PB1
8#define ENA PA8
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
📄 File: l298n_motor_driver_module_-_2a_dual_channel_-_raspberry_pi_pico.inoRaspberry Pi Pico
877 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// L298N: IN1=14, IN2=15, ENA(PWM speed)=16 on Raspberry Pi Pico. Motor's own power (up to several amps) comes from a separate supply into the driver board, never from the microcontroller pin.
6#define IN1 14
7#define IN2 15
8#define ENA 16
9
10void setup() {
11 Serial.begin(115200);
12 pinMode(IN1, OUTPUT);
13 pinMode(IN2, OUTPUT);
14 pinMode(ENA, OUTPUT);
15}
16
17void driveForward(int speed) { // speed 0-255
18 digitalWrite(IN1, HIGH);
19 digitalWrite(IN2, LOW);
20 analogWrite(ENA, speed);
21}
22
23void driveReverse(int speed) {
24 digitalWrite(IN1, LOW);
25 digitalWrite(IN2, HIGH);
26 analogWrite(ENA, speed);
27}
28
29void stopMotor() {
30 digitalWrite(IN1, LOW);
31 digitalWrite(IN2, LOW);
32}
33
34void loop() {
35 driveForward(200);
36 delay(2000);
37 stopMotor();
38 delay(500);
39 driveReverse(200);
40 delay(2000);
41 stopMotor();
42 delay(500);
43}
Dual H-bridge motor driver module - drives 2 DC motors, direction via IN pins, speed via PWM enable pin.
The L298N's internal transistors have a real voltage drop across them, which turns into real heat at higher currents - so treat the printed ”2A” rating as a peak figure, not a safe continuous one; for hot-running or higher-current motors, a MOSFET-based driver like the TB6612FNG runs cooler and more efficiently. If your motor supply exceeds 12V, remove the small onboard regulator-enable jumper before powering up - leaving it in place while feeding in more than 12V is one of the most common ways this module's onboard 5V regulator gets damaged. Also route motor and logic grounds to the same common ground point; a floating or separate ground between the microcontroller and the L298N is a frequent cause of erratic, seemingly random motor behavior.