

The L298N is a dual H-bridge motor driver designed to control the direction and speed of DC motors and stepper motors. It is a versatile and robust component capable of driving two motors simultaneously, with each channel supporting up to 2A of current. The L298N is widely used in robotics, automation, and other motor control applications due to its ease of use and compatibility with microcontrollers like Arduino.








The L298N module typically has the following pins:
| Pin Name | Type | Description |
|---|---|---|
| IN1 | Input | Motor A control input 1. Used to set the direction of Motor A. |
| IN2 | Input | Motor A control input 2. Used to set the direction of Motor A. |
| IN3 | Input | Motor B control input 1. Used to set the direction of Motor B. |
| IN4 | Input | Motor B control input 2. Used to set the direction of Motor B. |
| ENA | Input (PWM) | Enable pin for Motor A. Can be used for speed control via PWM. |
| ENB | Input (PWM) | Enable pin for Motor B. Can be used for speed control via PWM. |
| OUT1 | Output | Motor A output 1. Connects to one terminal of Motor A. |
| OUT2 | Output | Motor A output 2. Connects to the other terminal of Motor A. |
| OUT3 | Output | Motor B output 1. Connects to one terminal of Motor B. |
| OUT4 | Output | Motor B output 2. Connects to the other terminal of Motor B. |
| 12V | Power Input | External power supply for the motors (5V to 46V). |
| 5V | Power Output | Regulated 5V output (can power a microcontroller if the jumper is in place). |
| GND | Ground | Common ground for the module and external power supply. |
Note: Some L298N modules include a 5V-EN jumper. When this jumper is in place, the module's onboard voltage regulator provides 5V to the logic circuit. If using an external 5V supply, remove this jumper.
Power Connections:
Motor Connections:
Control Connections:
Logic Power:
Below is an example of how to control two DC motors using the L298N and an Arduino UNO:
// Define motor control pins
const int IN1 = 7; // Motor A direction pin 1
const int IN2 = 6; // Motor A direction pin 2
const int ENA = 5; // Motor A speed control (PWM)
const int IN3 = 4; // Motor B direction pin 1
const int IN4 = 3; // Motor B direction pin 2
const int ENB = 2; // Motor B speed control (PWM)
void setup() {
// Set motor control pins as outputs
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
}
void loop() {
// Motor A: Forward at 50% speed
digitalWrite(IN1, HIGH); // Set IN1 high
digitalWrite(IN2, LOW); // Set IN2 low
analogWrite(ENA, 128); // Set speed to 50% (128 out of 255)
// Motor B: Backward at 75% speed
digitalWrite(IN3, LOW); // Set IN3 low
digitalWrite(IN4, HIGH); // Set IN4 high
analogWrite(ENB, 192); // Set speed to 75% (192 out of 255)
delay(2000); // Run motors for 2 seconds
// Stop both motors
analogWrite(ENA, 0); // Stop Motor A
analogWrite(ENB, 0); // Stop Motor B
delay(2000); // Wait for 2 seconds
}
Motors Not Running:
Motors Running in the Wrong Direction:
Overheating:
No 5V Output:
Can the L298N drive stepper motors? Yes, the L298N can control stepper motors by driving the coils in sequence. Use a stepper motor library for easier implementation.
What is the maximum voltage the L298N can handle? The L298N can handle up to 46V on the motor power input (12V pin).
Can I use the L298N with a 3.3V microcontroller? The L298N requires 5V logic levels. Use a level shifter or a 5V microcontroller for compatibility.
Why is my motor running slowly? Check the PWM signal on the ENA/ENB pins and ensure the power supply voltage is adequate for the motor.