Introduction: How to Use the L298 Motor Driver Module - Arduino Tutorial

Picture of How to Use the L298 Motor Driver Module - Arduino Tutorial

This dual bidirectional motor driver is based on the very popular L298 Dual H-Bridge Motor Driver IC. This module will allow you to easily and independently control two motors of up to 2A each in both directions.

It is ideal for robotic applications and well suited for connection to a microcontroller requiring just a couple of control lines per motor.

In this tutorial you will learn how to use it with Arduino uno to control two dc motors.

Step 1: What You Will Need

Picture of What You Will Need

For this project you will need:

  • Arduino uno
  • Breadboard
  • L298 Module
  • 2x DC motors

Step 2: The Circuit

The connections are pretty easy!

  • Module 5V (or Vcc) - Arduino 5V pin
  • Module GND - Arduino GND pin
  • Module 12V (or Vbat) - To external power source up to 35V.
    For this tutorial just connect it with Arduino Vin pin.
  • Module output 1 & 2 - Connect dc motor A
  • Module output 3 & 4 - Connect dc motor B
  • Module IN1 - Arduino pin 5
  • Module IN2 - Arduino pin 6
  • Module IN3 - Arduino pin 10
  • Module IN4 - Arduino pin 9

Step 3: The Code

Here's the code, embedded using codebender!

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board!

You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code. For example try to combine parts of code to move both motors simultaneously.
Try to use analogWrite(pin, PWM value) instead digitalWrite(pin, HIGH/LOW) to control the speed of motors!

Step 4: Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use the L298 motor driver IC module to control two dc motors with the Arduino uno board.

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button!


AdalbertR (author)2018-01-11

Hi. I have a simple question. Why should we use this circuit with L298, instead of using the L298 only? Thanks.

matelot2 (author)2017-12-25

How are your driver pins numbered?

this is the only numbered picture I can find. The numbers don't correspond to yours?

amchiavelli (author)2017-08-05

Only with external power 12 volts.
With 5 volts did not work ...

VishanA (author)amchiavelli2017-12-16

when you use 5V of arduino the motor runs slow if you use 12v it will run fast

chameeracjw (author)amchiavelli2017-08-31

check whether the bridge is connected correctly. there is a bridge that decides which voltage give to your motor. If you connect it with 5V motors will have only 5V though you want to supply 12V. change the bridge and try!

AdrianP70 (author)2016-04-21

Can anyone help me out.I bought a l298n shield identical with the one in this tutorial, but mine isn't working at all.I've tried with arduino uno 5v, arduino mini 3.3v ,nodemcu esp8266 3.3v ,even straight from power supply (gnd and 9v) ,out1 and out2 with 9v motor conected and ENA(HIGH 5V) ,IN1(HIGH 5V),IN2(LOW GND) ,and still no power to motor (0,0v).Any ideas?

Maximus39 (author)AdrianP702017-07-17

Im having the same problem can anyone help

SiddarthN (author)Maximus392017-08-12

Ensure that the ENA and ENB jumpers are in place and you ave to use an external 12 V supply to the module.

SiddarthN (author)SiddarthN2017-08-12

When you supply 12v make sure that the USB is unplugged from your computer or else it may damage your motherboard.

amchiavelli (author)2017-08-05

It only work with the 12 volts power supply...

Pa11en made it! (author)2016-01-18

This tutorial made getting a start on my my robot car so much easier. It confirmed my my pc was talking to the Arduino and gave me some basic code to start with. A real confidence boost to get me started, Thank You. :)

Pa11en (author)Pa11en2017-02-09

The above link is now dead so I lost access to it.

About This Instructable




Bio: Arduino Tutorials by Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: