

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 capable of driving two motors simultaneously, making it an essential component in robotics, automation, and motor control projects. The L298n can handle high currents and voltages, making it suitable for a wide range of applications, from small hobbyist robots to industrial automation systems.








The L298n is a robust and versatile motor driver IC. Below are its key technical details:
The L298n IC has 15 pins, but it is often used with a breakout module for easier connections. Below is the pin configuration for the IC:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | Enable A | Enables or disables motor A (High = Enabled, Low = Disabled) |
| 2 | Input 1 | Logic input to control motor A direction (works with Input 2) |
| 3 | Output 1 | Output to motor A terminal 1 |
| 4 | Ground (GND) | Ground connection |
| 5 | Ground (GND) | Ground connection |
| 6 | Output 2 | Output to motor A terminal 2 |
| 7 | Input 2 | Logic input to control motor A direction (works with Input 1) |
| 8 | VSS (Logic Supply) | Logic voltage supply (typically 5V) |
| 9 | Enable B | Enables or disables motor B (High = Enabled, Low = Disabled) |
| 10 | Input 3 | Logic input to control motor B direction (works with Input 4) |
| 11 | Output 3 | Output to motor B terminal 1 |
| 12 | Ground (GND) | Ground connection |
| 13 | Ground (GND) | Ground connection |
| 14 | Output 4 | Output to motor B terminal 2 |
| 15 | Input 4 | Logic input to control motor B direction (works with Input 3) |
| 16 | VS (Motor Supply) | Motor voltage supply (up to 46V) |
For the L298n breakout module, additional pins like a 5V regulator jumper and onboard terminals for motor and power connections are included.
The L298n can be used to control two DC motors or one stepper motor. Below are the steps to use it in a circuit:
Power Supply:
VS pin (or the +12V terminal on the module).VSS pin.GND pins to the ground of your circuit.Motor Connections:
Output 1 and Output 2.Output 3 and Output 4.Control Pins:
Input 1 and Input 2 to control the direction of motor A.Input 3 and Input 4 to control the direction of motor B.Enable A and Enable B to enable or disable the motors. These pins can also be connected to a PWM signal to control motor speed.Optional:
Below is an example of how to control a DC motor using the L298n and an Arduino UNO:
// Define L298n control pins
const int enableA = 9; // PWM pin for motor A speed control
const int input1 = 8; // Direction control pin for motor A
const int input2 = 7; // Direction control pin for motor A
void setup() {
// Set control pins as outputs
pinMode(enableA, OUTPUT);
pinMode(input1, OUTPUT);
pinMode(input2, OUTPUT);
// Initialize motor A to stop
digitalWrite(input1, LOW);
digitalWrite(input2, LOW);
analogWrite(enableA, 0); // Set speed to 0
}
void loop() {
// Rotate motor A forward at 50% speed
digitalWrite(input1, HIGH);
digitalWrite(input2, LOW);
analogWrite(enableA, 128); // 50% duty cycle (128 out of 255)
delay(2000); // Run for 2 seconds
// Rotate motor A backward at full speed
digitalWrite(input1, LOW);
digitalWrite(input2, HIGH);
analogWrite(enableA, 255); // 100% duty cycle
delay(2000); // Run for 2 seconds
// Stop motor A
digitalWrite(input1, LOW);
digitalWrite(input2, LOW);
analogWrite(enableA, 0); // Set speed to 0
delay(2000); // Wait for 2 seconds
}
Motor Not Running:
Enable pins are set to HIGH.Overheating:
Erratic Motor Behavior:
PWM Not Controlling Speed:
Enable pins.Q: Can the L298n drive stepper motors?
A: Yes, the L298n can drive bipolar stepper motors by controlling the two H-bridge channels.
Q: What is the maximum current the L298n can handle?
A: The L298n can handle up to 2A per channel, but a heat sink is recommended for high-current applications.
Q: Can I use the L298n with a 3.3V microcontroller?
A: Yes, but you may need level shifters to ensure proper logic level compatibility.
Q: Is the onboard 5V regulator always active on the breakout module?
A: No, the 5V regulator is active only if the jumper is set and the motor supply voltage is above 7V.
By following this documentation, you can effectively use the L298n motor driver in your projects!