The L298N motor driver is one of the most widely used motor driver modules in the Arduino and robotics community. This dual H-bridge module can control two DC motors or one stepper motor, making it the go-to choice for robot cars, automated systems, and motor-based projects. In this complete guide, we cover the L298N’s working principle, wiring for DC motors and steppers, PWM speed control, and practical tips for managing heat.
What Is the L298N Module?
The L298N is a dual full-bridge driver IC designed by STMicroelectronics. The breakout module includes the IC, heatsink, power terminal blocks, header pins, and a voltage regulator. It can drive motors with voltages from 5V to 35V and handle up to 2A continuous current per channel (3A peak).
Key features:
- Two independent H-bridge channels (Motor A and Motor B)
- Direction control for each channel via two input pins
- Speed control via PWM on enable pins
- Built-in 5V regulator (when input voltage is 7-12V)
- On-board heatsink for the L298N IC
- Flyback diodes for motor back-EMF protection
How an H-Bridge Works
An H-bridge is a circuit arrangement of four transistors (or MOSFETs) that allows current to flow through a motor in either direction. The name comes from the H-shaped schematic:
- Four switches arranged in an H pattern with the motor in the crossbar
- Turning on the top-left and bottom-right switches drives current in one direction (forward)
- Turning on the top-right and bottom-left switches reverses current (reverse)
- Turning on both top or both bottom switches creates a short circuit (AVOID)
- Turning off all switches lets the motor coast to a stop
- Turning on both switches on one side creates a brake (motor stops quickly)
The L298N has two complete H-bridges, so it can independently control two motors’ speed and direction.
L298N Module Pinout
| Pin/Terminal | Function | Connection |
|---|---|---|
| +12V (VMS) | Motor power supply (5-35V) | Battery/power supply positive |
| GND | Common ground | Battery negative AND Arduino GND |
| +5V | 5V output (when jumper is on) | Can power Arduino (or input 5V if jumper removed) |
| ENA | Enable Motor A (PWM) | Arduino PWM pin (or jumper for full speed) |
| IN1 | Motor A direction input 1 | Arduino digital pin |
| IN2 | Motor A direction input 2 | Arduino digital pin |
| IN3 | Motor B direction input 1 | Arduino digital pin |
| IN4 | Motor B direction input 2 | Arduino digital pin |
| ENB | Enable Motor B (PWM) | Arduino PWM pin (or jumper for full speed) |
| OUT1, OUT2 | Motor A output | Motor A terminals |
| OUT3, OUT4 | Motor B output | Motor B terminals |
Wiring DC Motors with L298N
Components Required
- Arduino Uno
- L298N motor driver module
- Two DC motors (e.g., BO motors)
- Battery pack (7.4V-12V)
- Jumper wires
Wiring Connections
Power:
- Battery positive → L298N +12V terminal
- Battery negative → L298N GND terminal
- L298N GND → Arduino GND (common ground is essential)
- Keep the 5V jumper on to use L298N’s regulator to power Arduino via 5V pin
Motor A (Left):
- L298N ENA → Arduino pin 9 (PWM)
- L298N IN1 → Arduino pin 8
- L298N IN2 → Arduino pin 7
- Motor A wires → L298N OUT1 and OUT2
Motor B (Right):
- L298N ENB → Arduino pin 10 (PWM)
- L298N IN3 → Arduino pin 5
- L298N IN4 → Arduino pin 4
- Motor B wires → L298N OUT3 and OUT4
PWM Speed Control
The L298N’s enable pins (ENA, ENB) control motor speed through PWM (Pulse Width Modulation). Remove the jumper caps from ENA/ENB and connect them to Arduino PWM pins.
Direction Control Truth Table
| IN1 | IN2 | Motor Action |
|---|---|---|
| HIGH | LOW | Forward |
| LOW | HIGH | Reverse |
| LOW | LOW | Coast (free spin) |
| HIGH | HIGH | Brake (quick stop) |
Arduino Robot Car Code
// L298N Motor Driver - Robot Car Control
// Motor A (Left)
const int ENA = 9;
const int IN1 = 8;
const int IN2 = 7;
// Motor B (Right)
const int ENB = 10;
const int IN3 = 5;
const int IN4 = 4;
void setup() {
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
}
void moveForward(int speed) {
analogWrite(ENA, speed);
analogWrite(ENB, speed);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void moveBackward(int speed) {
analogWrite(ENA, speed);
analogWrite(ENB, speed);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
void turnLeft(int speed) {
analogWrite(ENA, speed / 2);
analogWrite(ENB, speed);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void turnRight(int speed) {
analogWrite(ENA, speed);
analogWrite(ENB, speed / 2);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void stopMotors() {
analogWrite(ENA, 0);
analogWrite(ENB, 0);
}
void loop() {
moveForward(200); // 0-255 speed
delay(2000);
turnRight(200);
delay(1000);
moveForward(200);
delay(2000);
turnLeft(200);
delay(1000);
moveBackward(150);
delay(2000);
stopMotors();
delay(3000);
}
Driving a Stepper Motor with L298N
The L298N can drive a bipolar stepper motor (like the NEMA 17) using both H-bridges. Each H-bridge controls one coil of the stepper motor.
Wiring:
- Stepper coil A → OUT1 and OUT2
- Stepper coil B → OUT3 and OUT4
- Remove jumpers from ENA and ENB, connect both to Arduino 5V (always enabled)
- IN1, IN2 control coil A; IN3, IN4 control coil B
Stepper Motor Code
#include <Stepper.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 7, 5, 4);
void setup() {
myStepper.setSpeed(60); // 60 RPM
Serial.begin(9600);
}
void loop() {
Serial.println("Clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
Serial.println("Counter-clockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
Heat Management and Efficiency
The L298N has a significant voltage drop across its internal transistors — typically 1.4-3V. This means if you supply 12V, the motor only receives about 9-10.6V. This wasted energy is converted to heat.
Tips for managing heat:
- The onboard heatsink handles normal loads, but add airflow for continuous high-current operation.
- For loads above 1.5A per motor, consider upgrading to a MOSFET-based driver (like the BTS7960 or TB6612FNG) which has much lower voltage drop.
- Use a higher voltage battery to compensate for the voltage drop if your motor needs a specific voltage.
- In hot Indian summers, ensure adequate ventilation around the driver module.
Frequently Asked Questions
Can the L298N handle 12V motors?
Yes, but remember the 1.4-3V voltage drop. A 12V motor on a 12V supply will only receive about 9-10.6V. Use a 14.8V (4S LiPo) or higher supply if you need the full 12V at the motor terminals.
Why is my L298N getting very hot?
The L298N uses BJT transistors which have inherent voltage drop (unlike MOSFETs). This is normal under high current loads. If the IC gets too hot to touch (above 70°C), reduce the current load, add a fan, or upgrade to a MOSFET-based driver like the BTS7960.
L298N vs L293D: Which should I use?
The L293D handles up to 600mA (1.2A peak) per channel and is suitable for small motors. The L298N handles up to 2A (3A peak) per channel. Use L293D for small BO motors and L298N for larger motors or when you need more current.
Can I drive 4 motors with one L298N?
No. The L298N has two channels. To drive four motors, you need two L298N modules. Alternatively, wire two motors in parallel per channel if they are identical motors that should move together (like tank drive).
Do I need to connect Arduino GND to L298N GND?
Yes, absolutely. The Arduino and L298N must share a common ground for the logic signals to work correctly. This is the most common mistake beginners make.
Conclusion
The L298N motor driver module is an affordable and versatile solution for controlling DC motors and stepper motors with Arduino. While it has limitations (voltage drop, heat), it remains the best starting point for robotics projects. As your projects grow more demanding, you can upgrade to more efficient drivers like the TB6612FNG or BTS7960.
Shop the L298N and other motor drivers at Zbotic.in and start building your next robot today.
Add comment