Menu Close

L298 high Current Double H Bridge Motor Driver Module

This tutorial of Robo India explains how to control the speed and direction of DC motor with Double H Bridge Motor Driver Module.

1. Introduction 

The Double H Bridge Motor Driver module is based on L298N chip manufactured by ST semiconductor.

It is a high voltage and high current full dual bridge driver designed to accept standard TTL logic level and drive inductive loads such as relays, solenoids and DC stepper motor.

1.1 Specification: 

1. Chip: L298N (ST).

2. Logical Voltage: 5V

3. Driving Voltage: 5V – 35V.

4. Logical Current: 0mA – 36mA.

5. Driving Current: 2A.

6. Maximum Power: 25W.

1.2 Working:

Enable A, Input Pin 1 and 2 is to control the output 1 and 2.

Enable B, Input Pin 3 and 4 is to control the output 3 and 4.

A jumper is preset on ENA and ENB pin, so that motor will be enable and work with their maximum speed. and when you want to control speed of rotating motors, remove that preset jumpers.

Another jumper is preset on +12V pin, to supply 5V power to other components of module.

 2. Hardware required

S.No.ItemQuantity
1Arduino UNO 1
2Double H Bridge Motor Driver 1
3DC Motor 2
4Female to Male Jumper wire 7
56xAA Battery 1

3. Connection:

with PWM Signals:

4. Programming:

You may download this code (Arduino Sketch) from here.

//Tutorial by RoboIndia on L298N Double H Bridge Motor Driver Module
//https://www.roboindia.com/tutorials/

int IN1 = 10;  //Motor B
int IN2 = 9;
int IN3 = 8;   //Motor B
int IN4 = 7;

  
void setup()
{
 // Set the output pins
 pinMode(IN1, OUTPUT);
 pinMode(IN2, OUTPUT);
 pinMode(IN3, OUTPUT);
 pinMode(IN4, OUTPUT);
}
  
void loop()
{

// Rotate the Motors clockwise
 digitalWrite(IN1, HIGH);
 digitalWrite(IN2, LOW);
 digitalWrite(IN3, HIGH);
 digitalWrite(IN4, LOW);
 delay(2000);
 // Rotate the Motors Anticlockwise
 digitalWrite(IN1, LOW);
 digitalWrite(IN2, HIGH);
 digitalWrite(IN3, LOW);
 digitalWrite(IN4, HIGH);
 delay(2000);
}

You may download this code (Arduino Sketch) with PWM Signals from here.

//Tutorial by RoboIndia on L298N Double H Bridge Motor Driver Module using PWM Signals
//https://www.roboindia.com/tutorials/
 
                              
int IN1  = 10;    //Motor A
int IN2  = 9;    
int IN3  = 8;    //Motor B
int IN4  = 7;    

//needs to be PWM pin to control speed
int EN1 = 11;                 // Pin 1 of L293D IC 
int EN2 = 6;                 // Pin 9 of L293D IC

void setup()
{
  pinMode(EN1, OUTPUT);   // where the motor is connected to
  pinMode(EN2, OUTPUT);   // where the motor is connected to
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);  
  Serial.begin(9600);
  Serial.println("Enter values between 0 - 255");
}

void loop()

{
  if(Serial.available())         
    { 
      int speed = Serial.parseInt();  //Receive Value from serial monitor
      Serial.println(speed);
        analogWrite(EN1, speed);      //sets the motors speed
        analogWrite(EN2, speed);      //sets the motors speed
        digitalWrite(IN1, HIGH);
        digitalWrite(IN2, LOW);
        digitalWrite(IN3, HIGH);
        digitalWrite(IN4, LOW);  
     }
}

 5. Output

After the connection you will copy and paste this code in Arduino IDE than upload the code.

The output of the first code is both connected motor will start rotating clockwise and then anticlockwise for 2 sec.

To get output of second code, Open the Serial Monitor and send the input values to Arduino. You can control the speed of the DC motor by sending different values between 0 -255.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply