Nairobi
admin@elffie.com
No image

Generic · L298N

L298N Motor Driver Module

KSh 300In stock

Specification

Part number
L298N
Manufacturer
Generic
Stock code
DRV-L298N
Category
DC Motors
Output type
H-bridge
Mounting
Screw terminal
Availability
26 in stock

Details

A dual H-bridge on a board with a heatsink and screw terminals — two DC motors forwards and backwards with speed control, or one stepper. The workhorse for small robots and anything with wheels.

It is an older bipolar design and drops a couple of volts across the bridge, so motors run slightly slower than the supply suggests and the heatsink gets warm under load. The on-board 5 V regulator can power your microcontroller, but only with the jumper fitted and the motor supply under roughly 12 V — above that, remove the jumper and feed the logic separately.

Ask about this part

Answers come from this listing and the assistant can still be wrong — the manufacturer's datasheet is what governs. For anything you are going to wire up, check it there or ask us.

Using this part

Starting points, not finished firmware. Check them against the datasheet.

Drive one motor both ways with speed control

cpp · 24 lines
// ENA -> D9 (PWM), IN1 -> D8, IN2 -> D7
// Motor supply to +12V/GND terminals, GND shared with the Arduino.

const uint8_t ENA = 9, IN1 = 8, IN2 = 7;

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

void drive(int speed) {          // -255..255
  bool forward = speed >= 0;
  digitalWrite(IN1, forward);
  digitalWrite(IN2, !forward);
  analogWrite(ENA, abs(speed) > 255 ? 255 : abs(speed));
}

void loop() {
  drive(200);   delay(2000);   // forward
  drive(0);     delay(500);    // stop
  drive(-200);  delay(2000);   // reverse
  drive(0);     delay(500);
}