Ordered on weekdays before 14:00 = shipped the same day and delivered the next day in 98% of cases. Free returns 30-day reflection period 1-year warranty

Wiring diagram and code example

How to connect the L298N Motor Driver Board red to an Arduino UNO or ESP32, with an example sketch you can upload straight away.

L298N Motor Driver Control with Arduino Uno

This example demonstrates how to control DC motors using an L298N motor driver board. The Arduino sets the motor rotation direction via digital logic pins and adjusts motor speed using PWM on the enable pin. The program cycles the motors forward, stops them, and then drives them in reverse.

Wiring diagram: L298N Motor Driver Board red on an Arduino UNO
Wiring diagram · Click to enlarge
Connection table: L298N Motor Driver Board red on an Arduino UNO
Connection table · Click to enlarge
L298N_Motor_Driver_Control_with_Arduino_.ino · compiled and verified
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : L298N Motor Driver Control with Arduino Uno
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : L298N Motor Driver Board
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// L298N Motor Driver Control Demo

const int ENA_PIN = 5;   // PWM speed control
const int IN1_PIN = 8;   // Motor A direction 1
const int IN2_PIN = 9;   // Motor A direction 2
const int IN3_PIN = 10;  // Motor B direction 1
const int IN4_PIN = 11;  // Motor B direction 2

void stopMotors() {
  digitalWrite(IN1_PIN, LOW);
  digitalWrite(IN2_PIN, LOW);
  digitalWrite(IN3_PIN, LOW);
  digitalWrite(IN4_PIN, LOW);
  analogWrite(ENA_PIN, 0);
}

void driveForward(int speedVal) {
  digitalWrite(IN1_PIN, HIGH);
  digitalWrite(IN2_PIN, LOW);
  digitalWrite(IN3_PIN, HIGH);
  digitalWrite(IN4_PIN, LOW);
  analogWrite(ENA_PIN, speedVal);
}

void driveReverse(int speedVal) {
  digitalWrite(IN1_PIN, LOW);
  digitalWrite(IN2_PIN, HIGH);
  digitalWrite(IN3_PIN, LOW);
  digitalWrite(IN4_PIN, HIGH);
  analogWrite(ENA_PIN, speedVal);
}

void setup() {
  Serial.begin(115200);
  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
  pinMode(IN3_PIN, OUTPUT);
  pinMode(IN4_PIN, OUTPUT);

  stopMotors();
  Serial.println(F("L298N Motor Driver initialized."));
}

void loop() {
  Serial.println(F("Driving forward"));
  driveForward(200);
  delay(2000);

  Serial.println(F("Stopping"));
  stopMotors();
  delay(1000);

  Serial.println(F("Driving reverse"));
  driveReverse(200);
  delay(2000);

  Serial.println(F("Stopping"));
  stopMotors();
  delay(1000);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

ESP32 Dual DC Motor Control with L298N

This project controls two DC motors using an ESP32 and an L298N H-bridge driver. The sketch rotates both motors forward, stops them, drives them in reverse, and demonstrates PWM speed control. Connect external power to the L298N 12V terminal to provide enough current for larger motors.

Wiring diagram: L298N Motor Driver Board red on an ESP32 DevKit V1
Wiring diagram · Click to enlarge
Connection table: L298N Motor Driver Board red on an ESP32 DevKit V1
Connection table · Click to enlarge
ESP32_Dual_DC_Motor_Control_with_L298N.ino · compiled and verified
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 Dual DC Motor Control with L298N
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : L298N Motor Driver Board
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

const int ENA_PIN = 14;
const int IN1_PIN = 27;
const int IN2_PIN = 26;
const int IN3_PIN = 25;
const int IN4_PIN = 33;
const int ENB_PIN = 32;

void setMotors(int speedA, int dirA, int speedB, int dirB) {
  // Motor A direction
  if (dirA > 0) {
    digitalWrite(IN1_PIN, HIGH);
    digitalWrite(IN2_PIN, LOW);
  } else if (dirA < 0) {
    digitalWrite(IN1_PIN, LOW);
    digitalWrite(IN2_PIN, HIGH);
  } else {
    digitalWrite(IN1_PIN, LOW);
    digitalWrite(IN2_PIN, LOW);
  }
  analogWrite(ENA_PIN, speedA);

  // Motor B direction
  if (dirB > 0) {
    digitalWrite(IN3_PIN, HIGH);
    digitalWrite(IN4_PIN, LOW);
  } else if (dirB < 0) {
    digitalWrite(IN3_PIN, LOW);
    digitalWrite(IN4_PIN, HIGH);
  } else {
    digitalWrite(IN3_PIN, LOW);
    digitalWrite(IN4_PIN, LOW);
  }
  analogWrite(ENB_PIN, speedB);
}

void setup() {
  Serial.begin(115200);
  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
  pinMode(IN3_PIN, OUTPUT);
  pinMode(IN4_PIN, OUTPUT);
  pinMode(ENB_PIN, OUTPUT);
  Serial.println("L298N Motor Driver Initialized");
}

void loop() {
  // Drive forward
  Serial.println("Moving Forward");
  setMotors(200, 1, 200, 1);
  delay(2000);

  // Stop
  Serial.println("Stopping");
  setMotors(0, 0, 0, 0);
  delay(1000);

  // Drive backward
  Serial.println("Moving Backward");
  setMotors(200, -1, 200, -1);
  delay(2000);

  // Stop
  Serial.println("Stopping");
  setMotors(0, 0, 0, 0);
  delay(1000);

  // Speed ramp up
  Serial.println("Ramping Speed Forward");
  for (int spd = 0; spd <= 255; spd += 15) {
    setMotors(spd, 1, spd, 1);
    delay(100);
  }
  delay(500);
  setMotors(0, 0, 0, 0);
  delay(1500);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

L298N Motor Driver Board – Dual H-Bridge for DC and Stepper Motors

With this L298N Motor Driver Board, you can easily control DC motors and stepper motors using, for example, an Arduino, ESP32, Raspberry Pi, microcontroller, or other digital control system.

The module is built around the well-known L298N Dual H-Bridge motor driver. Thanks to the two integrated H-bridges, you can independently control two standard brushed DC motors, including direction and speed control. In addition, the module can be used to drive one bipolar stepper motor.

According to the specifications of this module, the motor supply voltage can be between 5 and 35 V DC. The logic operates at 5 V. The L298N supports a current of up to 2 A per channel under suitable conditions, with good cooling being important at higher loads.

Suitable for DC motors

The L298N is not only intended for stepper motors. The board is very suitable for controlling standard brushed DC motors.

With one module, up to two DC motors can be controlled separately:

  • Motor A via OUT1 and OUT2
  • Motor B via OUT3 and OUT4

Through the digital inputs, you can determine the direction of rotation of each motor. Via the ENA and ENB connections, a PWM signal can also be applied to control the motor speed.

This makes the following functions possible, among others:

  • Run the motor forward
  • Run the motor backward
  • Stop the motor
  • Electric braking
  • Speed control with PWM
  • Control two motors independently

This makes the module suitable for robot cars, vehicles, small machines, actuators, fans, and other DC motor projects, among other things.

Suitable for stepper motors

The two H-bridges can also be used together to drive a bipolar stepper motor. The four motor outputs OUT1 through OUT4 are connected to the two coils of the stepper motor for this purpose.

The order in which IN1 through IN4 are driven then determines the direction of rotation and stepping pattern.

Speed control with PWM

For DC motors, the speed can be controlled via PWM (Pulse Width Modulation).

To do this, remove the jumpers from ENA and/or ENB and connect these pins to a PWM output of the microcontroller.

  • ENA: enable/PWM for motor A
  • ENB: enable/PWM for motor B

If the corresponding jumper remains installed, the channel is continuously enabled and the motor can be controlled via the IN pins without a separate PWM signal.

Connections

Power supply

Motor supply / VS
Connection for the supply voltage of the motors.

GND
Common ground for power and control. The GND of the microcontroller and the motor driver must be connected to each other.

5V
5V connection for the module logic. Depending on the configuration of the 5V regulator and jumper, this connection can function as either a power input or output.

Motor A

OUT1 / OUT2
Output of H-bridge A. DC motor A is connected here.

IN1 / IN2
Digital control inputs used to determine the direction of rotation of motor A.

ENA
Enable input for motor A. Can also be used for PWM speed control.

Motor B

OUT3 / OUT4
Output of H-bridge B. DC motor B is connected here.

IN3 / IN4
Digital control inputs used to determine the direction of rotation of motor B.

ENB
Enable input for motor B. Can also be used for PWM speed control.

Controlling a DC motor

ENA IN1 IN2 Function
HIGH HIGH LOW Direction of rotation 1
HIGH LOW HIGH Direction of rotation 2
HIGH LOW LOW Stop/brake
HIGH HIGH HIGH Stop/brake
LOW X X Output disabled

The actual direction of rotation depends on how the two motor wires are connected to OUT1 and OUT2.

For motor B, control works the same way via IN3, IN4, and ENB.

Technical specifications

  • Type: L298N Motor Driver Board
  • Driver IC: L298N
  • Driver technology: Dual H-Bridge / Dual Full Bridge
  • Suitable for: brushed DC motors and bipolar stepper motors
  • Number of DC motors: up to 2 independently controlled motors
  • Number of bipolar stepper motors: up to 1
  • Logic supply voltage: 5 V DC
  • Motor supply voltage module: 5 – 35 V DC
  • Maximum specified motor current: 2 A
  • Control: digital logic
  • DC motor speed control: PWM via ENA and ENB
  • Direction control: yes
  • Dual H-bridge: yes
  • Heatsink: yes
  • Motor outputs: OUT1, OUT2, OUT3 and OUT4
  • Control inputs: IN1, IN2, IN3 and IN4
  • Enable inputs: ENA and ENB
  • Dimensions: approximately 43 × 43 × 27 mm
  • Length: 43 mm
  • Width: 43 mm
  • Height: 27 mm
  • PCB color: red

L298N driver

The L298N used is a dual full-bridge driver specifically designed for switching inductive loads such as DC motors, stepper motors, relays, and solenoids. According to the manufacturer, the L298 itself supports a motor supply voltage of up to 46 V and includes thermal protection, among other features.

For this complete module, a motor supply voltage of 5 to 35 V DC is maintained.

Note on motor current

The specified maximum current of 2 A should be regarded as the maximum driver value. At higher continuous motor currents, significant heat loss occurs in the L298N. The practically usable continuous current therefore depends on, among other things, supply voltage, cooling, ambient temperature, and load.

Also check not only the nominal current of a DC motor, but also the startup and stall current. This can be several times higher than the current during normal operation.

Voltage drop across the driver

The L298N uses bipolar output transistors and therefore has a greater voltage drop than modern MOSFET motor drivers. The voltage that actually reaches the motor is therefore lower than the applied supply voltage.

This is especially relevant for low-voltage motors. For applications where very high efficiency or very low voltage drop is important, a modern MOSFET driver may be a better choice.

Applications

  • Arduino projects
  • ESP32 projects
  • Robot cars
  • Robotics
  • Two-wheel drives
  • DC motor control
  • PWM motor control
  • Reversible motors
  • Bipolar stepper motors
  • Small machines and mechanisms
  • Prototype and hobby electronics
  • Educational projects
  • Automation projects

Dimensions

  • Length: 4.3 cm
  • Width: 4.3 cm
  • Height: 2.7 cm

In summary

The L298N Motor Driver Board is a versatile dual H-bridge for controlling both standard DC motors and stepper motors. With one module, two DC motors can be driven independently forward and backward, and the speed can be controlled via PWM. Alternatively, both H-bridges can be used together for one bipolar stepper motor.

Thanks to its simple digital control, this module is very suitable for use with Arduino, ESP32, and other microcontrollers.

  • Dual H-Bridge
  • PWM control
  • For DC motors
  • For stepper motors

Why choose this product?

  • Two motors separately – Control of two DC motors independently.
  • Also stepper motors – Suitable for one bipolar stepper motor.
  • PWM speed control – Adjust speed via ENA and ENB.
  • Direction control – Motors forward, reverse, stop or brake.
Specifications
Dimensionsapprox. 43 × 43 × 27 mm
Suitable forbrushed DC motors and bipolar stepper motors
TypeL298N Motor Driver Board
Controldigital logic
Driver ICL298N
ENAenable/PWM for motor A
ENBenable/PWM for motor B
Driver technologyDual H-Bridge / Dual Full Bridge
Number of DC motorsup to 2 independently controlled motors
Number of bipolar stepper motorsup to 1
Logic supply voltage5 V DC
Motor supply voltage module5 – 35 V DC
Maximum rated motor current2 A
DC motor speed controlPWM via ENA and ENB
Direction controlyes
Dual H-bridgeyes
Heat sinkyes
Motor outputsOUT1, OUT2, OUT3 and OUT4
Control inputsIN1, IN2, IN3 and IN4
Enable inputsENA and ENB

Frequently bought together

Total: € 33,49

Reviews

★★★★★ 4,7/5 3 reviews
  • ★★★★★Yme

    Works well

  • ★★★★★Theo van RijnVerified purchase

    Works superbly. Better than with relays.

  • ★★★★★Alex

    Very neat compact little board.

Write a review
Your rating

Shipping & returns

Shipping

  • Parcel with track & trace€ 7,70Within 24 hours
  • Pick up at PostNL location€ 7,40Within 24 hours
  • Letterbox parcel€ 3,70Within 2 business days
  • Letterbox parcel 24 hours€ 4,55Within 24 hours
  • Pick up in storeFree
All about shipping

Returns

Not satisfied? You have 30 days after delivery to return the product.

All about returns

Recently viewed