4DVolt

L298N driver: pinout and wiring DC motors

The L298N module is a dual H-bridge: it controls the direction and speed of up to two DC motors, or one bipolar stepper motor. See the pinout, the jumpers, how to wire it to an Arduino, the code and test the drive in the simulator.

L298N motor driver module
L298N module

Specifications

Channels
2 H-bridges (motors A and B)
Motor supply (VS)
5 V to 35 V on the module
Current per channel
2 A continuous (3 A peak)
Logic
5 V (board regulator or 5V pin)
Input high level
from ≈ 2.3 V (works with 3.3 V)
Voltage drop
≈ 2 V at the outputs (bipolar transistors)
Maximum dissipation
25 W, with the heatsink

Pinout

The module has screw terminals (OUT1 to OUT4 for the motors, 12V, GND and 5V for power) and six control pins: ENA, IN1, IN2, IN3, IN4 and ENB.

Control (6 pins)

1 ENA Enables motor A; PWM sets the speed
2 IN1 Motor A direction input
3 IN2 Motor A direction input
4 IN3 Motor B direction input
5 IN4 Motor B direction input
6 ENB Enables motor B; PWM sets the speed

Screw terminals (7 positions)

1-2 OUT1, OUT2 Motor A
3 12V (VS) Motor supply, 5 V to 35 V
4 GND Common ground (motors, logic and Arduino)
5 5V 5 V output from the regulator or 5 V logic input
6-7 OUT3, OUT4 Motor B

L298N single-channel simulator

Adjust the VS voltage, the PWM on ENA and the IN1 and IN2 inputs and see the direction and the voltage at the motor.

State
Average motor voltage
Outputs

The motor voltage is the duty times (VS minus the ≈ 2 V output drop). Different IN1 and IN2 choose the direction; equal ones brake the motor. With ENA at 0 the outputs float.

How to wire it

Connect motor A between OUT1 and OUT2 and motor B between OUT3 and OUT4. Connect the motor supply to the 12V terminal and its GND to the module GND.

Join the module GND to the Arduino GND. Without a common ground the control signals have no reference and the motor does not respond.

Connect IN1 and IN2 (and IN3 and IN4) to digital pins and ENA (and ENB) to PWM pins, such as D5 and D6 on the Arduino Uno. IN1 HIGH and IN2 LOW turns one way; swapping them turns the other way.

Equal inputs brake the motor. With the enable LOW, the outputs float and the motor coasts to a stop.

Jumpers: the jumper on ENA or ENB keeps the channel always enabled (full speed); remove it to use PWM. The 5V-EN jumper turns on the onboard 5 V regulator and can stay on with VS up to 12 V. Above 12 V remove it and power the logic through the 5V pin.

The ≈ 2 V drop at the outputs lowers the voltage that reaches the motor. For a 6 V motor, supply 8 V or more.

Example code (Arduino)

Sketch that spins motor A forward, stops, then spins it backward, changing the speed with PWM (ENA = 5, IN1 = 7, IN2 = 8).

#define ENA 5
#define IN1 7
#define IN2 8

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
}

void loop() {
  digitalWrite(IN1, HIGH);   // forward
  digitalWrite(IN2, LOW);
  analogWrite(ENA, 200);     // ≈ 78% speed
  delay(2000);

  analogWrite(ENA, 0);       // stop
  delay(1000);

  digitalWrite(IN1, LOW);    // reverse
  digitalWrite(IN2, HIGH);
  analogWrite(ENA, 120);     // ≈ 47% speed
  delay(2000);

  analogWrite(ENA, 0);
  delay(1000);
}

Common mistakes

  • Forgetting to connect the module GND to the Arduino GND: the signals have no reference.
  • Leaving the jumper on ENA and trying to control speed with PWM: the channel stays at full speed.
  • Powering a 6 V motor with 6 V: the ≈ 2 V drop leaves only 4 V at the motor and it runs weak.
  • Using the 5V-EN jumper with VS above 12 V: the regulator overheats and burns out. Remove the jumper and power the logic separately.
  • Connecting a motor that draws more than 2 A: the chip overheats, shuts down or burns. Use a MOSFET driver.
  • Powering the Arduino and the motors from the same battery without a capacitor: motor start-up drops the voltage and resets the board.

Always check the manufacturer's datasheet for your exact model: pin order can vary between modules.

Frequently asked questions

What is an H-bridge?

It is an arrangement of four switches that lets you reverse the polarity applied to a motor. Closing the switches one way spins the motor forward, the other way backward.

How do I control speed with the L298N?

Apply PWM with analogWrite on the ENA (or ENB) pin. The higher the duty, the higher the average voltage at the motor and the faster it spins.

Can the L298N drive a stepper motor?

Yes, bipolar steppers: each coil goes to one channel and the four inputs IN1 to IN4 are driven in sequence. For current control, the A4988 and DRV8825 drivers are better.

Can I use the L298N with an ESP32?

Yes. The inputs accept 3.3 V and the ESP32 generates PWM on any output GPIO. Power the 5 V logic from the module regulator and join the grounds.

Why does the L298N get hot?

Bipolar transistors drop ≈ 2 V per output and dissipate it as heat. Use the heatsink and, for larger motors, prefer MOSFET drivers.

Other components