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.
Explore Projects Built with L298N
Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
This is a robotic control circuit featuring an Arduino UNO microcontroller that interfaces with two SG90 servo motors for movement, an HC-SR04 ultrasonic sensor for distance measurement, and an HC-05 Bluetooth module for wireless communication. The L298N motor driver is incorporated for potential motor control, and the system is powered through a standard power jack.
This circuit is designed to control a mobile platform with four DC motors for movement, two servos for directional control, and an ESP32-CAM module for wireless video streaming. The L298N motor driver interfaces with the ESP32-CAM to drive the motors based on commands received over WiFi, allowing for remote directional control. The ESP32-CAM also handles the servo positioning and streams live video, enabling the user to control and monitor the platform remotely through a web interface.
This circuit is a line-following robot controller. It uses a Nano 3.0 ATmega328P microcontroller to read inputs from a line sensor and control two DC motors via an L298N motor driver. Power is supplied by a 9V battery regulated through an XL4015 DC buck converter.
This circuit is designed to control a two-wheeled robot using an L298N motor driver, powered by two 18650 Li-ion batteries. It includes two KY-033 line tracking sensors for navigation and a 74HC04 inverter to process sensor signals and control the motor driver inputs.
Automation: Controlling conveyor belts or actuators
DIY Projects: Building remote-controlled cars or robotic arms
Stepper Motor Control: Precise positioning in CNC machines or 3D printers
Technical Specifications
Key Technical Details
Operating Voltage: 5V to 46V
Output Current: Up to 2A per channel (continuous)
Peak Current: 3A per channel (short duration)
Logic Voltage: 5V
Control Logic Levels: High (1) = 5V, Low (0) = 0V
Power Dissipation: 25W (with proper heat sinking)
Built-in Protection: Thermal shutdown and overcurrent protection
Dimensions: Typically 43mm x 43mm (for L298N modules)
Pin Configuration and Descriptions
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.
Usage Instructions
How to Use the L298N in a Circuit
Power Connections:
Connect the 12V pin to an external power source (5V to 46V) suitable for your motors.
Connect the GND pin to the ground of the power source and the microcontroller.
If the onboard 5V regulator is used, ensure the 5V-EN jumper is in place.
Motor Connections:
Connect Motor A to OUT1 and OUT2.
Connect Motor B to OUT3 and OUT4.
Control Connections:
Connect IN1, IN2, IN3, and IN4 to the microcontroller's digital pins.
Connect ENA and ENB to PWM-capable pins on the microcontroller for speed control.
Logic Power:
If the 5V-EN jumper is removed, provide 5V to the 5V pin from an external source (e.g., Arduino).
Example Arduino Code
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
}
Important Considerations and Best Practices
Heat Dissipation: The L298N can get hot during operation. Use a heat sink or active cooling for high-current applications.
Power Supply: Ensure the motor power supply voltage matches the motor's specifications.
Current Limits: Do not exceed the 2A continuous current rating per channel to avoid damage.
Grounding: Connect all grounds (module, power supply, and microcontroller) to a common ground.
Troubleshooting and FAQs
Common Issues and Solutions
Motors Not Running:
Check power connections and ensure the external power supply is sufficient.
Verify that the control pins (IN1, IN2, etc.) are receiving the correct signals.
Motors Running in the Wrong Direction:
Swap the connections of IN1 and IN2 (or IN3 and IN4) to reverse the motor direction.
Overheating:
Ensure the module has adequate heat dissipation (e.g., heat sink or fan).
Reduce the motor load or use motors with lower current requirements.
No 5V Output:
Check if the 5V-EN jumper is in place. If removed, provide an external 5V supply.
FAQs
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.