

The L298N is a dual H-bridge motor driver IC designed to control the direction and speed of DC motors and stepper motors. It is widely used in robotics and automation projects due to its ability to drive two motors simultaneously with a maximum current of 2A per channel. The L298N is a versatile and robust component, making it ideal for applications such as robotic arms, motorized vehicles, conveyor belts, and other motor-driven systems.








The L298N module typically comes with a breakout board for easier use. Below is the pin configuration for the module:
| 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 signal. |
| ENB | Input (PWM) | Enable pin for Motor B. Can be used for speed control via PWM signal. |
| OUT1 | Output | Motor A output 1. Connect to one terminal of Motor A. |
| OUT2 | Output | Motor A output 2. Connect to the other terminal of Motor A. |
| OUT3 | Output | Motor B output 1. Connect to one terminal of Motor B. |
| OUT4 | Output | Motor B output 2. Connect to the other terminal of Motor B. |
| VCC | Power Input | Motor power supply (5V to 46V). |
| GND | Power Ground | Ground connection. |
| 5V | Power Output | Provides 5V output (useful for powering logic circuits if the motor voltage |
| exceeds 7V). |
Power Connections:
VCC pin (ensure it matches the motor's voltage rating).GND pin to the ground of your power supply and the ground of your control circuit.5V pin to power your control logic.Motor Connections:
OUT1 and OUT2.OUT3 and OUT4.Control Connections:
IN1 and IN2 pins to control the direction of Motor A.IN3 and IN4 pins to control the direction of Motor B.ENA and ENB pins to enable/disable the motors or control their speed using a PWM signal.Logic Control:
IN1, IN2, IN3, IN4, ENA, ENB) to a microcontroller or other control circuit.Below is an example of how to control a DC motor using the L298N and Arduino UNO:
// Define control pins for Motor A
const int IN1 = 9; // Motor A direction control pin 1
const int IN2 = 8; // Motor A direction control pin 2
const int ENA = 10; // Motor A speed control (PWM) pin
void setup() {
// Set motor control pins as outputs
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
}
void loop() {
// Rotate motor forward
digitalWrite(IN1, HIGH); // Set IN1 high
digitalWrite(IN2, LOW); // Set IN2 low
analogWrite(ENA, 150); // Set speed (0-255)
delay(2000); // Run motor for 2 seconds
// Rotate motor backward
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, HIGH); // Set IN2 high
analogWrite(ENA, 150); // Set speed (0-255)
delay(2000); // Run motor for 2 seconds
// Stop motor
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, LOW); // Set IN2 low
analogWrite(ENA, 0); // Set speed to 0
delay(2000); // Wait for 2 seconds
}
Motor Not Running:
ENA or ENB pins are enabled (set high or receiving a PWM signal).Overheating:
Erratic Motor Behavior:
Q: Can the L298N drive stepper motors?
A: Yes, the L298N can drive stepper motors by controlling the sequence of the H-bridge inputs. However, additional software logic is required to generate the correct stepping sequence.
Q: Can I use the L298N with a 3.3V microcontroller?
A: The L298N is designed for 5V logic levels. If using a 3.3V microcontroller, level shifters may be required for reliable operation.
Q: What is the purpose of the 5V pin on the module?
A: The 5V pin provides a regulated 5V output when the motor power supply exceeds 7V. It can be used to power the control logic or other low-power components.
Q: How do I control motor speed with the L298N?
A: Motor speed can be controlled by applying a PWM signal to the ENA or ENB pins. The duty cycle of the PWM signal determines the motor speed.