The L298N Motor Driver, manufactured by Arduino (Part ID: L298N), is a dual H-bridge motor driver designed to control two DC motors or one stepper motor. It supports motor voltage ranges from 5V to 35V and can handle up to 2A per channel, making it ideal for robotics and automation projects. The L298N allows for precise control of motor speed and direction, making it a popular choice for hobbyists and professionals alike.
Below are the key technical details of the L298N Motor Driver:
Parameter | Value |
---|---|
Operating Voltage | 5V to 35V |
Output Current | Up to 2A per channel |
Logic Voltage | 5V |
Control Logic Levels | High: 2.3V to 5V, Low: 0V |
Number of Channels | 2 (dual H-bridge) |
Power Dissipation | 25W (with proper heat sink) |
Dimensions | 43mm x 43mm x 27mm |
The L298N module has several pins and terminals for motor control and power input. Below is a detailed description:
Pin/Terminal | Description |
---|---|
VCC | Motor power supply (5V to 35V). |
GND | Ground connection. |
5V | Logic power supply (optional, if not using onboard regulator). |
OUT1, OUT2 | Outputs for Motor A. |
OUT3, OUT4 | Outputs for Motor B. |
Pin | Description |
---|---|
ENA | Enable pin for Motor A (PWM input for speed control). |
ENB | Enable pin for Motor B (PWM input for speed control). |
IN1, IN2 | Control pins for Motor A direction. |
IN3, IN4 | Control pins for Motor B direction. |
Power Connections:
Motor Connections:
Control Connections:
Logic Power:
Below is an example code to control two DC motors using the L298N Motor Driver with an Arduino UNO:
// Define control pins for Motor A
const int ENA = 9; // PWM pin for speed control
const int IN1 = 8; // Direction control pin 1
const int IN2 = 7; // Direction control pin 2
// Define control pins for Motor B
const int ENB = 10; // PWM pin for speed control
const int IN3 = 6; // Direction control pin 1
const int IN4 = 5; // Direction control pin 2
void setup() {
// Set motor control pins as outputs
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, 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 (0-255)
// Motor B: Backward at 75% speed
digitalWrite(IN3, LOW); // Set IN3 low
digitalWrite(IN4, HIGH); // Set IN4 high
analogWrite(ENB, 192); // Set speed (0-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 Output Voltage on Motor Terminals:
Q: Can the L298N drive stepper motors?
A: Yes, the L298N can drive a bipolar stepper motor by controlling the two H-bridges. However, additional code is required to generate the step sequence.
Q: Can I use the onboard 5V regulator to power my Arduino?
A: Yes, but only if the motor power supply is between 7V and 12V. For higher voltages, use a separate 5V power supply for the Arduino.
Q: What is the maximum PWM frequency supported?
A: The L298N typically supports PWM frequencies up to 20 kHz.
Q: Can I control more than two motors with one L298N?
A: No, the L298N is designed to control up to two DC motors or one stepper motor. For more motors, additional drivers are required.