Skip to content

Step by step on how to use the L298n dual H-bridge driver with Arduino



Hello everybody,

Welcome to this tutorial, check the video first it contains a little bit of explanation about H-bridges if you want to understand or even make your own one.
If you’re a bit familiar with DC motors (motors widely used in toys and robots) you’ll notice that if you switch polarity the rotation direction will change too, so in order to go forward and backward you need to switch the wires… but that’s not practical, you need something to do it electronically without modifying any wires: This is where the H-bridge comes handy.

The module I used is a L298n Dual H-bridge, it’s often used with Arduino, it can control 2 DC motors at the same time, and you can control the direction and the speed as well. This module can control a Stepper motor as well ( but that’s for another day), in case you need to control your stepper motor, here’s an alternative: How to use a stepper motor with Arduino and its driver ULN2003.

Here are some circuit schematics that I took from wikipedia:

Just in the practical form, the switches are replaced by “Transistors” and every two (verticales) are control by a single pin, that’s why on the module you’ll notice 4 controlling pins, 2 for each motor.

Here’s a picture of the module pins that I took from

L298n module pinout


  • The “Logic Input” pins control the directions: Forward, Backward and Stop, each two of them control A motor.
  • 12V power is not always 12V it can be 9V, or it can be powered using up to 47VDC but you have to remove the regulator jumper or you’ll burn it, the regulator can support only up to 12V.
  • Enable A/B are for controlling the speed, if their jumpers are kept, the speed will be the maximum, they can handle up to 5V
  • The module can be powered using Arduino but that’s not recommended at all, it’s better to use external power, and you can power the Arduino through the module too via the 5V/Gnd pins
  • Don’t forget that the GND pin should always be wired with Arduino.

Wirings: (no speed control)

The one that permits speed control is below.

Wiring 1: Power the module

Wiring 2: Wiring the module with Arduino (without speed control)

Codes: (no speed control)

Code 1: Direct turn on


Code 2: Turn on and change the direction


Wiring 3: For speed control

Don’t forget to remove the enA/B jumper

Code: Speed control

Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

4 thoughts on “Step by step on how to use the L298n dual H-bridge driver with Arduino Leave a comment

Leave a Reply

%d bloggers like this: