This guide shows how to use the L298N motor driver with Arduino wiring. It explains the voltage drop inside the Darlington transistors, how to set jumpers, and how to isolate noise.
Quick answer
To set up the L298N motor driver with Arduino wiring, connect the Arduino digital pins to the driver's IN1 and IN2 inputs (direction control) and a PWM-capable pin to the ENA pin (speed control). Connect the external motor power supply (7V-35V) to the L298N 12V terminal, and tie the external power supply ground and Arduino ground together at the L298N GND terminal. Keep the onboard 5V regulator jumper closed if your motor supply is under 12V; otherwise, remove it and supply independent 5V logic power.
Internal Architecture and Electrical Limits of the L298N
The L298N is a high-voltage, high-current dual full-bridge driver designed to accept standard TTL logic levels. Unlike modern MOSFET-based motor drivers, the L298N utilizes bipolar junction transistors (BJTs) configured as Darlington pairs. This internal silicon architecture introduces a notable technical constraint: a high internal voltage drop. Depending on the current draw, this voltage drop typically ranges from 1.4V to over 2.0V between the input power supply and the motor terminals. Consequently, if you connect a 9V battery to power a 9V motor, the motor will only receive approximately 7V. Engineers must account for this loss by selecting a supply voltage higher than the nominal rating of the motor.
The module can drive up to two DC motors or one bipolar stepper motor. Each channel is rated for a continuous current of 2.0A, with peak currents up to 3.0A under transient conditions. However, due to the high saturation voltage of the BJTs, the L298N dissipates a significant amount of energy as heat. Operating near the 2A limit requires a substantial heatsink and often active cooling to prevent thermal shutdown. This thermal inefficiency makes the driver less suitable for battery-critical applications, but its low cost and electrical robustness make it a standard tool for bench testing, laboratory prototyping, and academic robotics projects.
For a closely related example, see Research on seat active noise control of driver’s cab ground platform based on far-point secondary sound sources.
Onboard 5V Regulator Jumper Selection Matrix
Use this decision framework to configure the L298N jumper correctly based on your motor supply voltage ($V_M$). Incorrect configuration can destroy the onboard regulator or fail to power the internal logic gates.
| Factor | Engineering view | Why it matters |
|---|---|---|
| Motor Supply (5V to 12V) | Keep Jumper Closed (Inserted) | Onboard 78M05 regulator active. 5V terminal acts as an output to power low-current logic. |
| Motor Supply (12V to 35V) | Remove Jumper (Open) | Onboard regulator disabled to prevent thermal damage. Must supply external 5V to the 5V terminal. |
| Motor Supply (< 5V) | Remove Jumper (Open) | Supply voltage is below regulator dropout threshold. Must supply external 5V to the 5V terminal. |
Demystifying the Power Terminals and Regulator Jumper
The standard L298N breakout board has a three-terminal screw block that is the main power connector. The three terminals are named 12V, GND, and 5V. Knowing how these terminals work with the onboard 5V regulator jumper is important so you donβt damage your microcontroller. The board includes a 78M05 5V regulator that supplies clean logic voltage to the internal L298N logic gates. If the 5V regulator jumper is placed (closed), the regulator turns on and takes its input straight from the 12V terminal. In that case, the 5V terminal becomes an output.
You can connect this output to power an Arduino, as long as the Arduino and any attached sensors draw less current than the regulatorβs safe limit (usually about 200mA to 300mA after allowing for heat loss). If the motor supply voltage applied to the 12V terminal goes above 12V, the regulator can overheat and break. When this happens, you must take out the jumper. With the jumper removed, the regulator is turned off and the 5V terminal works as an input. You then need to feed a regulated 5V voltage to that terminal to run the driverβs internal logic.
If you forget to remove the jumper and apply more than 12V to the motor terminal, the regulator will fail right away and you could damage other parts with too high a voltage.
For a closely related example, see A Systematic Approach to Digital Control Development for Four-Phase SRM Drive Using Single Current Sensor for Medium Power Applications.
Complete L298N Motor Driver with Arduino Wiring Schematic
Implementing the L298N motor driver with Arduino wiring requires careful separation of the high-current motor power loop and the low-current logic control loop. The primary connection point for isolating these systems is the common ground terminal. To wire a single DC motor (Motor A) for bidirectional speed control, connect the components as follows:
First, connect the external motor power supply's positive lead to the 12V terminal of the L298N. Connect the negative lead of the external power supply to the L298N GND terminal. Next, run a jumper wire from the L298N GND terminal directly to one of the GND pins on the Arduino.
This common ground connection is non-negotiable; without it, the control signals from the Arduino will lack a reference potential, causing erratic motor behavior or complete control failure. For control signals, remove the jumper from the ENA (Enable A) pins on the breakout board. Connect the ENA pin to Arduino digital pin 9. This pin is PWM-enabled on the Arduino Uno, allowing for speed modulation. Connect IN1 to Arduino digital pin 8, and IN2 to Arduino digital pin 7. These two pins dictate the current flow direction through the H-bridge. Finally, connect the two terminals of your DC motor to the OUT1 and OUT2 screw terminals on the L298N board.
For a closely related example, see Discrete-Time PID Speed Control for DC Motor via Z-Transform: Performance Analysis Across Simulation and Embedded Implementation Environments.
L298N Control Input Truth Table
The direction and braking state of each motor channel are governed by the digital voltage states applied to the input pins.
| Factor | Engineering view | Why it matters |
|---|---|---|
| IN1 = HIGH, IN2 = LOW | Motor Spins Clockwise / Forward | Current flows from OUT1 to OUT2. |
| IN1 = LOW, IN2 = HIGH | Motor Spins Counter-Clockwise / Reverse | Current flows from OUT2 to OUT1. |
| IN1 = LOW, IN2 = LOW | Active Stop (Coast) | Outputs float; motor decelerates naturally based on friction. |
| IN1 = HIGH, IN2 = HIGH | Active Brake | Outputs are shorted to ground; motor stops rapidly. |
Control Logic and Arduino Firmware Implementation
The direction of Motor A is controlled by the logical states of the IN1 and IN2 pins. Setting IN1 to HIGH and IN2 to LOW routes current through the H-bridge in one direction, causing the motor to spin forward. Reversing these states (IN1 to LOW, IN2 to HIGH) reverses the current path, spinning the motor backward. If both pins are set to the same logical state (either both HIGH or both LOW), the motor stops. Setting both to LOW allows the motor to coast to a stop, while setting both to HIGH acts as an active brake. Speed is regulated by applying a PWM signal to the ENA pin.
The Arduino analogWrite() function generates a square wave at approximately 490 Hz (or 980 Hz on specific pins) with a variable duty cycle from 0 (always off) to 255 (always on). Below is a verified, syntactically correct Arduino C++ sketch to validate this wiring configuration. It cycles the motor through forward acceleration, braking, reverse acceleration, and coasting:
// Verified L298N Control Sketch
const int enA = 9; // PWM pin for speed control
const int in1 = 8; // Direction control pin 1
const int in2 = 7; // Direction control pin 2
void setup() {
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
// Initialize motor in stopped state
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
analogWrite(enA, 0);
}
void loop() {
// 1. Spin Forward at Medium Speed
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, 150);
delay(3000);
// 2. Active Brake
digitalWrite(in1, HIGH);
digitalWrite(in2, HIGH);
delay(1000);
// 3. Spin Reverse at Full Speed
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(enA, 255);
delay(3000);
// 4. Coast to Stop
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
analogWrite(enA, 0);
delay(2000);
}
Power Distribution and Inductive Noise Isolation
DC motors are very inductive loads. They create a lot of electromagnetic interference (EMI) and voltage spikes when they start, stop, or change direction. If you try to power a DC motor straight from the Arduino's 5V or 3.3V power rails, the microcontroller will likely brown out, reset, or be permanently damaged by back electromotive force (back-EMF). To reduce inductive noise, always power the motors with a separate source, like a benchtop supply, a LiPo battery pack, or an isolated AC-DC adapter. Most good L298N breakout boards have built-in flyback diodes placed across each output channel.
These diodes clamp voltage spikes and send them safely back to the power rails. If your board does not have these diodes, you need to add external 1N4007 fast-recovery diodes across the motor terminals. Also, solder a 0.1uF ceramic capacitor directly across the motorβs metal terminals to reduce high-frequency brush noise. Use separate power routes (star-grounding) that return to the common ground terminal on the L298N. This keeps motor return currents away from the Arduinoβs logic ground and protects signal integrity.
Pre-Power Hardware Verification Checklist
Complete these physical checks before applying power to the L298N or Arduino to prevent hardware damage.
- Common Ground: Verified (Arduino GND is connected directly to the L298N GND terminal.)
- Regulator Jumper: Verified (Jumper is removed if motor power supply exceeds 12V.)
- PWM Pin Capability: Verified (ENA/ENB lines are connected to pins with a tilde symbol (~) on the Arduino board.)
- No Short Circuits: Verified (No stray copper strands bridging adjacent screw terminals on the power block.)
Diagnostic Guide for Common Integration Failures
When troubleshooting a newly wired L298N system, systematically isolating the power supply from the control signals is the most efficient path to resolution. The most common error is a missing common ground wire between the Arduino and the L298N. If this connection is absent, the control inputs on the L298N will float, leading to either no movement or sporadic, uncontrolled motor twitching. Another common symptom is a high-pitched humming sound from the motor without any physical rotation.
This indicates that the PWM duty cycle is too low to overcome the static friction of the motor gearhead, or that the power supply voltage is insufficient once the L298N's internal 2V Darlington drop is subtracted. Increasing the value in analogWrite() or increasing the supply voltage typically resolves this issue. If the motor spins in only one direction regardless of the code commands, inspect the logic voltages at the IN1 and IN2 pins using a digital multimeter.
If one pin remains stuck at 0V or 5V regardless of the Arduino's output state, check for physical wiring breaks, cold solder joints on the breakout board headers, or a damaged output driver channel on the microcontroller.
Useful research starting points
Key takeaways
- The L298N driver has an internal voltage drop of up to 2V due to its BJT Darlington architecture, which must be factored into motor power supply calculations.
- A common ground connection between the Arduino and the L298N is mandatory for the control logic to function correctly.
- The onboard 5V regulator jumper must be removed if the motor supply voltage exceeds 12V to prevent regulator failure.
- Speed control is achieved by removing the ENA/ENB jumpers and applying a hardware PWM signal from the Arduino.
- Always power DC motors from an external power source rather than the Arduino's power rails to prevent brownouts and inductive damage.
Questions engineers often ask
Why does my motor hum but not spin when connected to the L298N?
This usually happens when the voltage reaching the motor is too low to overcome its internal friction. Because the L298N drops about 1.5V to 2V internally, a 5V or 6V supply may only deliver 3V to 4V to the motor. Additionally, a very low PWM value (e.g., under 100 in analogWrite) might not provide enough torque. Try increasing your external supply voltage or raising the PWM duty cycle in your code.
Can I use the L298N to control a stepper motor?
Yes. The L298N contains two complete H-bridges, which makes it capable of driving a single bipolar stepper motor. You will need to wire the two coils of the stepper motor to OUT1/OUT2 and OUT3/OUT4 respectively, and use the standard Arduino Stepper library to control the step sequence.
Do I need to keep the ENA and ENB jumpers on the board?
Only if you do not need speed control. Keeping the jumpers on ties the enable pins directly to 5V, which means the motors will always run at 100% speed when active. If you want to control the speed using PWM, you must remove these jumpers and connect the enable pins directly to PWM-capable Arduino pins.
Why does my Arduino reset whenever the motor starts spinning?
This is a classic symptom of electrical noise or voltage sag. If you are sharing a power supply between the Arduino and the L298N, the sudden current draw of the motor starting can pull down the voltage enough to trigger the Arduino's brown-out reset. To fix this, use separate power supplies for the motor and the microcontroller, ensuring only the grounds are tied together.
Continue learning: l298n motor driver with arduino wiring
Explore more mechatronics and control systems tutorials at Fried Engineers.