How to Use the L298N Motor Driver

Control your DC motors effectively with the versatile L298N motor driver.

What Is the L298N Motor Driver?

The L298N is a high-power dual H-bridge motor driver that allows you to control the direction and speed of two DC motors or a stepper motor. It supports high current loads and is perfect for robotics and automation projects.

Key Features

Connecting the L298N

Follow these steps to connect the L298N to your microcontroller:

  1. Connect VCC to your motor power supply (5V–35V).
  2. Attach GND to the ground of both the motor and the microcontroller.
  3. Connect IN1–IN4 to digital pins on your microcontroller for motor control.
  4. Use the EN A and EN B pins to enable/disable motor channels.
  5. Connect your DC motors to the OUT1/OUT2 and OUT3/OUT4 terminals.

Arduino Example Code


#define ENA 9
#define IN1 8
#define IN2 7

void setup() {
    pinMode(ENA, OUTPUT);
    pinMode(IN1, OUTPUT);
    pinMode(IN2, OUTPUT);
}

void loop() {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    analogWrite(ENA, 128); // Set speed
    delay(2000);

    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
    analogWrite(ENA, 128); // Reverse direction
    delay(2000);
}