Arduino Projects

Arduino L298n Motor Driver control Tutorial, Speed & Direction, PWM

L298N Motor Driver with Arduino Description:


This is a getting started tutorial on how to use the L298N motor driver and control the forward, left, right, and reverse movement. in this tutorial, you will also learn how to use the pulse width modulation to control the speed of a dc motor. For the best understanding, I will explain two Arduino programs, the first program will explain only the basics like for example, how to control the direction of a robot using L298N motor driver. While in the 2nd program I will also add the PWM to control the Speed of DC Motors.   This Tutorial Covers

  1. Robot parts assembling
  2. L298N motor driver Pinout and explanation.
  3. L298N Interfacing with Arduino
  4. Programming and finally number
  5. Testing

I have also used the same L298N motor driver for controlling the stepper motor.

For the complete step-by-step explanation, you can watch the video given at the end of this Article.

Amazon Links:

Arduino Nano USB-C Type (Recommended)

12v Adaptor:

Robot Car chassis kit:

L298N motor driver:

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Robot Parts Assembling:


First of all, I started by fixing the motors.



After fixing both the Motors, then I installed both the wheels.


After I was done with the Motors and wheels, then I Started fixing the front wheel.


Then I installed the Battery Holder.


Finally with the help of two long Bolts I made a base for the L298N motor driver.



With this my Robot Parts assembling completed. Now before I explain anything else first let’s have a look at the L298N motor driver and it’s Pinout.

L298N Motor Driver:


This is the L298N dual H-bridge Motor driver. This motor driver can be used to control Dc motors that have voltages between 5 and 35volts, with a peak current of up to 2amps. As this is a dual H-Bridge motor driver, it can be used to control the speed and direction of two DC motors at the same time.

Now let’s take a closer look at the Pinout of L298N module.


This module has three terminal blocks. terminal block1 will be used for motor A and is clearly labeled with out1 and out2, this is where we connect the two wires of the dc motor. Terminal block2 will be used for motor B  and is clearly labeled with out3 and out4.


While the terminal block3 is labeled with 12v, ground and +5v.


The 12v terminal is used to supply the voltage to the dc motors, this voltage can be from 5 to 35volts. The ground terminal is connected with the ground of the external power supply and is also connected with the ground of the controller board, which in my case is Arduino board which


As you can see this motor driver also have some male headers which are clearly labeled with ENA…IN1…IN2…IN3…IN4 and ENB. The ENA and ENB are used to enable both the motors. Jumper caps mean that both the motors are enabled by default and the motors will rotate at maximum speed. If the jumper caps are removed and the ENA and ENB pins are connected with the PWM pins of the Arduino, the motors speed can be controlled using the pulse width modulation which I will explain in the programming. Then IN1 and IN2 pins are used for controlling the direction of motor A while the IN3 and IN4 are used to control the direction of motor B. now let’s start the interfacing.

L298N Motor Driver Interfacing With Arduino:

First of all fix the motor driver and Arduino.



Connect the red wire of the left motor with out1.


Now connect the black wire of the left motor with out2.


Connect the red wire of the right motor with out3 and connect the black wire of the right motor with out4.


These are the two wires coming from the battery holder.


Connect the red wire with the +12v terminal and connect the black wire with the ground terminal and also connect the ground terminal with the Arduino’s ground.



Now connect the +5v terminal of the motor driver with the Arduino’s 5v.



Now remove the jumper caps and connect two jumper wires with the ENA and ENB pins. Connect ENA with pin number 5 of the Arduino which is the PWM pin and connect the ENB pin with pin number 6 which is also a PWM pin.



now connect jumper wires with IN1, IN2, IN3 and IN4 AND connect IN1 with pin number8, connect IN2 with pin number 9, connect IN3 with pin number 10, and connect IN4 with pin number 11.L298N

So we are done with the interfacing and now let’s control the motors forward, left, right and reverse movement and also control the speed of the dc motors.

Note: if you have missed any connection and face any Problem, you can watch video given at the end of this Article. In the video each and every connection is clearly explained.

L298N Arduino Program Number1:

The purpose of this program is to explain how to control the forward, left, right and reverse movement of the motors using L298N motor driver. While in the next program I have explained the speed controlling.

First of all, I started off by defining all the Pins of the L298N motor driver. As explained during the interfacing, the ena and enb Pins of the L298N motor driver are connected with the Arduino’s Pin Number 5 and Pin number 6. Pin number 5 and Pin number 6 both are the PWM Pins of the Arduino Uno.

The In1, In2, In3 and In4 Pins of the L298N Motor driver are connected with Pins 8, 9, 10, and 11 of the Arduino.

255 means that the motors are set at their maximum speed.

L298N Speed Control Programming:

All the connections remain the same.

Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button