L298N Dual Motor Controller H‑Bridge Driver Module User’s Guide



Overview
The L298N module is a dual H‑bridge motor driver that allows you to control the speed and direction of two DC motors or one stepper motor. It can handle up to 2 A per channel with supply voltages from 5 V to 35 V. It’s widely used with Arduino, ESP32, Raspberry Pi, and other microcontrollers.
Pinout & Connections
| Pin/Terminal | Function |
|---|---|
| ENA / ENB | Enable pins for Motor A and Motor B (PWM input for speed control). |
| IN1, IN2 | Control inputs for Motor A (direction). |
| IN3, IN4 | Control inputs for Motor B (direction). |
| OUT1, OUT2 | Motor A outputs. |
| OUT3, OUT4 | Motor B outputs. |
| +12V | Motor power supply (up to 35 V). |
| +5V | Logic supply (can be sourced from onboard regulator if jumper is set). |
| GND | Common ground. |
Operation Logic
- Motor Direction Control
- IN1 = HIGH, IN2 = LOW → Motor A forward
- IN1 = LOW, IN2 = HIGH → Motor A reverse
- IN1 = IN2 → Motor A stop
- Speed Control
- Apply PWM signal to ENA/ENB pins.
- Duty cycle controls motor speed.
Example Wiring with Arduino
// Motor A pins
int ENA = 9;
int IN1 = 8;
int IN2 = 7;
// Motor B pins
int ENB = 3;
int IN3 = 5;
int IN4 = 4;
void setup() {
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
}
void loop() {
// Motor A forward
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 200); // speed (0–255)
// Motor B reverse
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENB, 150); // speed
}
Applications
- Robotics (two‑wheel drive robots)
- CNC machines and 3D printers (stepper control)
- Automated toys and DIY kits
- Conveyor belts and small automation projects
Best Practices
- Use a separate power supply for motors (avoid drawing heavy current from Arduino).
- Add flyback diodes if motors are highly inductive (though L298N has internal diodes).
- Keep heat sink exposed — the IC can get hot at >1 A loads.
- Use PWM for smooth speed control.
- Tie all grounds together (motor supply, logic supply, microcontroller).