Component
L298N motor driver with Arduino: pinout, wiring and code
The L298N is a dual H-bridge motor driver. It lets an Arduino set the speed and direction of two DC motors, or four wired in pairs, from their own battery. Wire ENA and ENB to PWM pins and IN1–IN4 to any digital pins, join the two boards’ grounds, and pull the ENA/ENB jumper caps off.
The Arduino decides. The L298N does the pushing. It is the one part in this car that can be destroyed by a wiring mistake, and the one whose behaviour most often gets blamed on the code.
L298N pinout
The module has three groups of connections: a screw terminal for power, two screw terminals for the motors, and a row of header pins for the Arduino.
| Pin | Group | What it does |
|---|---|---|
+12V | power | motor supply in, 5–35V despite the label |
GND | power | ground; must also connect to the Arduino’s GND |
+5V | power | 5V out from the onboard regulator while the 5V-enable jumper is on |
OUT1, OUT2 | motor A | one motor, or one side of the car |
OUT3, OUT4 | motor B | the other motor or side |
ENA | control | speed of motor A, from a PWM pin |
IN1, IN2 | control | direction of motor A |
IN3, IN4 | control | direction of motor B |
ENB | control | speed of motor B, from a PWM pin |
Two channels, A and B. This car wires the two left motors in parallel to one channel and the two right motors to the other, which is how one L298N drives four wheels.
Why an Arduino needs a motor driver
An Arduino pin can signal, but it cannot push. A pin supplies roughly 20 milliamps. One of the gear motors in this build wants a few hundred. Wire a motor straight to a pin and you do not get a slow car — you get a dead Arduino.
So the driver sits in between. The battery feeds it directly, and the Arduino only tells it which way and how hard, over six thin signal wires carrying almost no current at all.
How it works, in one paragraph
Inside each half of the board is an H-bridge: four switches arranged in a square with the motor across the middle. Close the top-left and bottom-right pair and current runs through the motor one way. Close the other diagonal and it runs the other way. That is the entire trick behind reverse, and it is why each side needs two direction pins, IN1 and IN2, rather than one.
IN1 HIGH, IN2 LOW. S1 and S4 close. Current runs from the battery through the motor left to right, and it turns one way.
IN1 LOW, IN2 HIGH. The other diagonal, S2 and S3. Current crosses the motor right to left, and it turns the other way.
IN1 and IN2 the same (shown: both LOW, so S3 and S4 close). Both motor leads are tied together. The spinning motor’s own current loops back through it and stops it fast.
ENA at 0. Every switch opens. The motor is cut loose and freewheels to a stop.
IN1 | IN2 | Motor A |
|---|---|---|
| HIGH | LOW | turns one way |
| LOW | HIGH | turns the other way |
| LOW | LOW | brakes to a stop |
| HIGH | HIGH | brakes to a stop |
That is with ENA driven. Set ENA to 0 instead and the motor is cut loose and coasts, which is what stopMotors() in the sketch below does. IN3 and IN4 do the same for motor B. Which way counts as “forward” depends only on which way round the motor leads sit in the screw terminal.
Wiring it to the Arduino
Six male-to-female jumper wires, straight across:
| Arduino pin | L298N pin | What it does |
|---|---|---|
5 | ENA | speed, left side |
6 | ENB | speed, right side |
9 | IN4 | direction |
10 | IN3 | |
11 | IN2 | |
12 | IN1 |
IN1–IN4 choose direction. ENA and ENB control speed, and they only work on Arduino pins that can do PWM — switching on and off fast enough that the motor averages it out. That is why they sit on pins 5 and 6 rather than anywhere convenient.
The two jumpers, and only one of them matters here
The board ships with small jumper caps on it, and they are not the same jumper. Confusing them is why speed control gets blamed on the sketch.
The ENA / ENB caps — pull these off. Most boards arrive with a cap bridging each enable pin to +5V. That ties the enables permanently high and overrides whatever the Arduino sends. Every speed then behaves as full speed, and no change to the code makes the slightest difference. On the reference car with both caps removed, speed 1 crawls and speed 9 runs — which is only possible with them off.
The 5V-enable jumper — leave this one alone. Different jumper, different job: it feeds the board’s onboard regulator from the main supply. It only has to come off when you power the board above 12V, at which point you supply 5V separately. This car runs on two 18650 cells, so it never gets near that. Leave it on.
Powering it
The battery holder’s red lead goes into +12V and black into GND, screwed down. Then the same two leads go across to the Arduino as well:
| Battery lead | L298N | Arduino |
|---|---|---|
| Red + | +12V | Vin |
| Black − | GND | GND |

+12V and Vin; black to GND on both boards.That second pair does two jobs at once. It powers the Arduino, so the car does not die the moment you unplug the USB cable. And it gives the two boards a shared ground, which is what lets the driver understand the signals from the six wires above. Without it the wiring looks perfectly correct and nothing works.
Polarity destroys this board. Red to +12V, black to GND. The wrong way round kills the driver outright. Wire the battery last, every time, and check it twice — it is the only step in the whole build that can damage anything.
Test it: L298N Arduino code
Before the Bluetooth code goes on, prove the driver and the wiring on their own. This sketch uses the exact pins in the table above: it ramps both sides forward from slow to full speed, stops, reverses, stops, and repeats. Lift the car off the table first.
// L298N test: the same pins as the Troniction car.
#define enA 5 // speed, left side (PWM)
#define enB 6 // speed, right side (PWM)
#define in1 12
#define in2 11
#define in3 10
#define in4 9
void forward() {
digitalWrite(in1, LOW); digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH); digitalWrite(in4, LOW);
}
void backward() {
digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
digitalWrite(in3, LOW); digitalWrite(in4, HIGH);
}
void stopMotors() {
analogWrite(enA, 0);
analogWrite(enB, 0);
}
void setSpeed(int speed) { // 0 to 255
analogWrite(enA, speed);
analogWrite(enB, speed);
}
void setup() {
pinMode(enA, OUTPUT); pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT); pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT); pinMode(in4, OUTPUT);
stopMotors();
}
void loop() {
forward();
for (int s = 100; s <= 255; s += 5) { // slow to full speed
setSpeed(s);
delay(60);
}
delay(1000);
stopMotors();
delay(1000);
backward();
setSpeed(180);
delay(2000);
stopMotors();
delay(2000);
}
If the ramp at the start does nothing visible and the car goes straight to full speed, the ENA/ENB caps are still on. If one side runs backwards, swap that side’s two leads in its OUT terminal. The full car sketch, with Bluetooth, is step 3 of the build guide.
When it does not work
| What you see | Most likely cause |
|---|---|
| Nothing moves; the red power LED is on | No shared ground between the L298N and the Arduino, or ENA/ENB not connected to pins 5 and 6 |
| Nothing moves; no LED | No power reaching +12V/GND: check the battery switch, the cells, and that the screws are clamping bare wire, not insulation |
| Motors only ever run at full speed | The ENA/ENB jumper caps are still on |
| One side runs backwards | That side’s motor leads are swapped in its OUT terminal |
| Motors hum but do not turn | Speed value too low for the motors to start, or the battery is low; remember the driver takes about 2V first |
| The Arduino resets when the motors start | The battery sags under load and the Uno browns out; charge the cells |
| The chip gets hot | Normal in use; this is a lossy driver and the heatsink is there for it |
L298N voltage drop: the 2V it takes
An H-bridge is not free. The L298N drops roughly 2V across it, so the motors never see the full pack voltage — with the 7.4V pack in this build they get about 5.4V, which lands neatly inside the TT motors’ 3–6V rating.
That is the real reason this car uses a two-cell pack rather than three. Three 18650s would be 11.1V; take 2V off and the motors would still see around 9V, against a 6V rating. The chassis and gear motors page has the same arithmetic from the motor’s side.
An honest note about the battery
Two 18650 cells are 7.4V nominal, 8.4V fully charged. The Uno’s recommended Vin range is 7–12V, so this car spends its life at the very bottom of that range. It works — the reference car has run this way for years — but it means the Arduino browns out well before the cells are actually flat. If the car starts behaving strangely, charge it before you start debugging it.
Which one to buy
Get the screw-terminal version, around $8. That is the part that keeps this build solder-free: the motor leads and the battery leads land in the terminal block and are tightened with a small Phillips screwdriver. Boards sold without that block need an iron, and there is no soldering anywhere else in this car.

L298N specifications
For the module as it is sold, for reference rather than reading. These are the sellers’ figures, not ST’s: the L298 chip itself is rated to 46V and 4A in total, and the module’s lower 35V ceiling comes from the two 35V capacitors on the board.
| Spec | Value |
|---|---|
| Logic voltage | 5V |
| Drive voltage | 5V – 35V |
| Logic current | 0 – 36mA |
| Drive current | 2A max per bridge |
| Max power | 25W |
| Size / weight | 43 × 43 × 27mm, 30g |
Download the L298 datasheet if you want STMicroelectronics’ own document, or read the datasheet explained. It covers the chip only; the red module around it has no official datasheet.
Where this fits
Three parts decide how this car behaves: the Arduino Uno makes the decisions, the L298N does the pushing, and the HC-06 listens to your phone. What it pushes is on the chassis and gear motors page, and what powers it on 18650 cells. The wiring itself is step 2 of the build guide; every part has a page, and the whole build is free to read.
Every part of the car
Common questions
- Should I remove the ENA and ENB jumpers on the L298N?
- Yes, if you want speed control from the Arduino. The caps tie ENA and ENB to 5V, which holds both channels at full speed whatever the Arduino sends. Pull them off and wire ENA and ENB to PWM pins, as this car does with pins 5 and 6.
- What does the 5V jumper on the L298N do?
- It lets the onboard regulator make 5V for the board's logic from the motor supply. Leave it on for supplies up to 12V. Remove it above 12V and supply 5V to the +5V pin yourself.
- Can an L298N drive four motors?
- Yes, as two pairs. It has two channels; wire the two left motors in parallel to one and the two right motors to the other. Each pair then turns together, which is exactly what a car needs.
- Why are my motors slower on the L298N than on the battery directly?
- The L298N drops roughly 2V across itself. With a 7.4V pack the motors see about 5.4V. That loss is normal for this chip.
- Do the L298N and the Arduino need a common ground?
- Yes. Without a wire between the two GND pins the driver cannot read the Arduino's signals, and the wiring looks correct while nothing moves.
Build it. Understand it.
Get the complete illustrated guide and start your first car — free.
