Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
The L298N Motor Driver is a popular dual H-Bridge motor driver which allows speed and direction control of two DC motors at the same time. It’s widely used in robotics and embedded systems due to its simplicity, low cost, and ability to drive two motors simultaneously.
The L298N is a dual H-bridge motor driver IC. It is the core component of the motor driver module, enabling control of two DC motors (or one stepper motor). It allows you to:
The L298N can work with a wide range of voltages from 5V to 46V. This made it very powerful to handle small to large motors.
The 78M05 is a voltage regulator built into the module.
The 5V jumper is a small, removable bridge on the module.
Note: Do not connect Arduino’s 5v pin to the L298N logic supply input pin (5v) as long as the 5v regulator’s jumper is placed.
When input voltage ≤ 12V and jumper is placed, the onboard 78M05 voltage regulator is activated. The 5V pin acts as an output and can be used to power a microcontroller or other 5V devices.
When input voltage > 12V, the jumper must be removed to prevent damage to the regulator. The 5V pin must be used as an input. A separate regulated 5V input must be supplied via the 5V terminal to power the internal circuitry.
These pins are connected to the outputs of the H-bridge circuits inside the L298N IC and are used to drive DC motors or stepper motors.
The direction of the motor’s rotation can be controlled by applying logic HIGH (5V) or logic LOW (0V) to the input pins (IN1 and IN2 for Motor A, IN3 and IN4 for Motor B). By changing the logic levels on these pins, you can control the current flow through the motor, thereby determining its spinning direction.
| Input1 | Input2 | Spinning Direction |
| Low | Low | Motor stops |
| High | Low | Forward |
| Low | High | Backward |
| High | High | Motor stops |
By default, the module comes with jumpers across ENA and ENB, connecting them directly to 5V. This causes both motors to run at full speed when powered.
To control motor speed using an Arduino (or any microcontroller):
For more information, visit Getting to Know Your Arduino Uno: A Beginner’s Guide to Its Components.
| L298N Motor Driver | Arduino |
| IN1 | D8 |
| IN2 | D7 |
| IN3 | D5 |
| IN4 | D4 |
| ENA | D9 |
| ENB | D3 |
Connect the red wire of the battery holder to the 12V screw terminal and the black wire to the GND screw terminal.
| L298N Motor Driver | Arduino |
| 5V | VIN |
| GND | GND |
int motor1pin1 = 8;
int motor1pin2 = 7;
int motor2pin1 = 5;
int motor2pin2 = 4;
int ena = 9;
int enb = 3;
void setup() {
pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(motor2pin1, OUTPUT);
pinMode(motor2pin2, OUTPUT);
pinMode(ena, OUTPUT);
pinMode(enb, OUTPUT);
}
void loop() {
// Clockwise max speed
analogWrite(ena, 250);
analogWrite(enb, 250);
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
delay(2000);
// Stop
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
delay(2000);
// Counter Clockwise max speed
analogWrite(ena, 250);
analogWrite(enb, 250);
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, HIGH);
delay(2000);
// Stop
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
delay(2000);
// Clockwise half speed
analogWrite(ena, 127);
analogWrite(enb, 127);
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
delay(2000);
// Stop
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
delay(2000);
// Counter Clockwise half speed
analogWrite(ena, 127);
analogWrite(enb, 127);
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, HIGH);
delay(2000);
}