• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Get free circuit help 24/7

New Projects | Privacy Policy | About us | Contact | Disclaimer | Copyright | Videos 

You are here: Home / Arduino Engineering Projects / L298N DC Motor Driver Module Explained

L298N DC Motor Driver Module Explained

Last Updated on March 8, 2019 by Swagatam

In this post we are going to learn about L298N dual H-bridge DC motor driver module which can be used to drive brushed DC motors and stepper motors with microcontrollers and ICs.

Overview

Modular circuit boards are best time savior for electronics designers which also reduce the prototyping errors. This is mostly preferred by programmers who write code for microcontrollers spend their majority of the time by typing codes in front of the computer and have less time for solder the discrete electronic components.

That’s why we can find tons and tons of different modular circuits are made just for Arduino boards, it is easy to interface and have advantage of least hardware errors while designing our prototype.

Illustration of L298N module:

 

Illustration of L298N module:

caution electricity can be dangerous

The module is built around IC L298N; it is commonly available at E-commerce websites.

We use DC motor drivers because the ICs and microcontrollers are not capable of delivering current not more than 100 milliamps in general. The microcontrollers are smart but not strong; this module will add some muscles to Arduino, ICs and other microcontrollers to drive high power DC motors.

It can control 2 DC motors simultaneously up to 2 amps each or one stepper motor. We can control the speed using PWM and also its rotational direction of the motors.

This module is ideal for building robots and land moving projects such as toy cars.

Let’s see the technical details of L298N module.

technical details of L298N module.

Pin description:

· On the left hand side there are OUT1 and OUT2 port, which is for connecting DC motor. Similarly, OUT3 and OUT4 for another DC motor.

· ENA and ENB are enable pins, by connecting ENA to high or +5V; it enables the port OUT1 and OUT2. If you connect the ENA pin to low or ground, it disables the OUT1 and OUT2. Similarly, for ENB and OUT3 and OUT4.

· IN1 to IN4 are the input pins which will be connected to Arduino. If you input IN1 +Ve and IN2 –Ve from microcontroller or manually, the OUT1 turns high and OUT2 turns low, thus we can drive motor.

· If you input IN3 high, OUT4 turns high and if you input IN4 low OUT3 turns low, now we can drive another motor.

· If you want to reverse the rotational direction of the motor just reverse IN1 and IN2 polarity, similarly for IN3 and IN4.

· By applying PWM signal to ENA and ENB you can control the speed of the motors on two different output ports.

· The board can accept from 7 to 12V nominally. You can input power at +12V terminal and ground to 0V.

· The +5V terminal is OUTPUT which can be used to power Arduino or any other module if needed.

Jumpers:

There are three jumper pins; you can scroll up see the illustrated image.

All the jumpers will be connected initially; remove or keep the jumper depending on your need.

Jumper 1 (see illustrated image):

· If you’re motor need more than 12V supply you have to disconnect the jumper 1 and apply desired voltage (maximum 35V) at 12v terminal. Bring another 5V supply and input at +5V terminal. Yes, you have to input 5V if you need to apply more than 12V (when jumper 1 is removed).

· The 5V input is for proper functioning of the IC, since removing the jumper will disable the in-built 5v regulator and protect from higher input voltage from 12v terminal.

· The +5V terminal acts as output if your supply is between 7 to 12V and acts as input if you apply more than 12V and jumper is removed.

· Most of the projects just need motor voltage below 12V so, keep the jumper as it is and use +5V terminal as output.

Jumper 2 and Jumper 3 (see illustrated image):

· If you remove these two jumpers you have to input the enable and disable signal from the microcontroller, most of the users prefer removing the two jumpers and applying the signal from microcontroller.

· If you keep the two jumpers the OUT1 to OUT4 will be always enabled. Remember ENA jumper for OUT1 and OUT2. ENB jumper for OUT3 and OUT4.

Now let’s see a practical circuit, how can we interface motors, Arduino and supply to the driver module.

Schematic:

 

schematic diagram of L298N module.

 

The above circuit can be used for toy cars, if you change the code appropriately and add a joystick.

You just need to power the L289N module and the module will power the Arduino via Vin terminal.

The above circuit will rotate the both motors clock-wise for 3 second and stop for 3 second. After that the motor will rotate anti-clockwise for 3 seconds and stop for 3 seconds. This demonstrates the H-bridge in action.

After that both the motor will start rotating slowly in anti-clockwise gaining speed gradually to maximum and gradually reduce the speed to zero. This demonstrates speed control of motors by PWM.

Program:

//----------------Program developed by R.GIRISH--------------//
const int Enable_A = 9;
const int Enable_B = 10;
const int inputA1 = 2;
const int inputA2 = 3;
const int inputB1 = 4;
const int inputB2 = 5;
void setup()
{
pinMode(Enable_A, OUTPUT);
pinMode(Enable_B, OUTPUT);
pinMode(inputA1, OUTPUT);
pinMode(inputA2, OUTPUT);
pinMode(inputB1, OUTPUT);
pinMode(inputB2, OUTPUT);
}
void loop()
{
//----Enable output A and B------//
digitalWrite(Enable_A, HIGH);
digitalWrite(Enable_B, HIGH);
//----------Run motors-----------//
digitalWrite(inputA1, HIGH);
digitalWrite(inputA2, LOW);
digitalWrite(inputB1 , HIGH);
digitalWrite(inputB2, LOW);
delay(3000);
//-------Disable Motors----------//
digitalWrite(Enable_A, LOW);
digitalWrite(Enable_B, LOW);
delay(3000);
//-------Reverse Motors----------//
digitalWrite(Enable_A, HIGH);
digitalWrite(Enable_B, HIGH);
digitalWrite(inputA1, LOW);
digitalWrite(inputA2, HIGH);
digitalWrite(inputB1 , LOW);
digitalWrite(inputB2, HIGH);
delay(3000);
//-------Disable Motors----------//
digitalWrite(Enable_A, LOW);
digitalWrite(Enable_B, LOW);
delay(3000);
//----------Speed rise----------//
for(int i = 0; i < 256; i++)
{
analogWrite(Enable_A, i);
analogWrite(Enable_B, i);
delay(40);
}
//----------Speed fall----------//
for(int j = 256; j > 0; j--)
{
analogWrite(Enable_A, j);
analogWrite(Enable_B, j);
delay(40);
}
//-------Disable Motors----------//
digitalWrite(Enable_A, LOW);
digitalWrite(Enable_B, LOW);
delay(3000);
}
//----------------Program developed by R.GIRISH--------------//

Author’s prototype:

Arduino prototype of motor driver circuit using of L298N module.

If you have any questions regarding this L298N DC motor driver project, feel free to express in the comment section, you may receive a quick reply.

You'll also like:

  • 1.  Incubator Using Arduino with Automatic Temperature and Humidity control
  • 2.  Stepper Motor Driver Circuit using IC 555
  • 3.  How to Interface 4×4 Keypad with Arduino
  • 4.  PWM Motor Soft Start Circuit to Prevent High Consumption during Power Switch ON
  • 5.  Arduino Tachometer Circuit for Precise Readings
  • 6.  Make this 7 Segment Digital Clock with Beep Alert Circuit

About Swagatam

I am an electronic engineer (dipIETE ), hobbyist, inventor, schematic/PCB designer, manufacturer. I am also the founder of the website: https://www.homemade-circuits.com/, where I love sharing my innovative circuit ideas and tutorials.
If you have any circuit related query, you may interact through comments, I'll be most happy to help!

Have Questions? Please Comment below to Solve your Queries! Comments must be Related to the above Topic!!

9 Comments
Newest
Oldest
Inline Feedbacks
View all comments

Primary Sidebar

Categories

  • 3-Phase Power (15)
  • 324 IC Circuits (19)
  • 4017 IC Circuits (52)
  • 4060 IC Circuits (26)
  • 555 IC Circuits (99)
  • 741 IC Circuits (20)
  • Arduino Engineering Projects (83)
  • Audio and Amplifier Projects (115)
  • Battery Chargers (83)
  • Car and Motorcycle (94)
  • Datasheets (73)
  • Decorative Lighting (Diwali, Christmas) (33)
  • Electronic Components (101)
  • Electronic Devices and Circuit Theory (36)
  • Electronics Tutorial (120)
  • Fish Aquarium (5)
  • Free Energy (34)
  • Fun Projects (13)
  • GSM Projects (9)
  • Health Related (20)
  • Heater Controllers (29)
  • Home Electrical Circuits (103)
  • How to Articles (20)
  • Incubator Related (6)
  • Industrial Electronics (28)
  • Infrared (IR) (40)
  • Inverter Circuits (98)
  • Laser Projects (12)
  • LED and Light Effect (93)
  • LM317/LM338 (21)
  • LM3915 IC (25)
  • Meters and Testers (66)
  • Mini Projects (149)
  • Motor Controller (67)
  • MPPT (7)
  • Oscillator Circuits (26)
  • PIR (Passive Infrared) (8)
  • Power Electronics (34)
  • Power Supply Circuits (79)
  • Radio Circuits (10)
  • Remote Control (48)
  • Security and Alarm (62)
  • Sensors and Detectors (121)
  • SG3525 IC (5)
  • Simple Circuits (75)
  • SMPS (29)
  • Solar Controllers (61)
  • Timer and Delay Relay (53)
  • TL494 IC (5)
  • Transformerless Power Supply (8)
  • Transmitter Circuits (41)
  • Ultrasonic Projects (16)
  • Water Level Controller (45)

Calculators

  • AWG to Millimeter Converter
  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator

© 2023 · Swagatam Innovations

wpDiscuz