How to connect an H-BRIDGE DUAL Motor driver module to the Arduino

SUMMARY
In this tutorial, you will learn how to connect the H-BRIDGE DUAL Motor driver module to t.he arduino and drive two dc motors at 9v
ABOUT
Category: Arduino
Difficulty: Beginner
Submitted by: Gideon
Date: 28th January, 2018
OVERVIEW
This H-Bridge dual motor driver module uses the L298N dual full-bridge driver. It is a high voltage, high current dual full-bridge driver designed to accept standard TTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors.
DETAILS
The driver can drive up to two motors. The H-Bridge dual motor driver module is connected to the arduino where it receives signals. The signal pins on the driver are four, two for each motor. One signal pin makes the motor move in a particular direction of rotation but the other one makes it move the opposite way. This same principle works for the other motor. The driver receives an input voltage from 5v to 12v . There is a voltage regulator that sets the voltage down. This power source can be used to power the arduino board.
You can get a motor driver at Invent electronics
Here is a complete list of components needed for this circuit
- Arduino Nano
- Bread board(optional)
- Male- female Jumper wires
- H-Bridge dual motor driver
This is how the H-bridge looks like. It has two terminal blocks which each side has a motor with two wires connecting to it. This tutorial will require the driver to power two motors in a robot. The four signal pins connect to the arduino GPIO pins and the power(GND and 5v ) goes to the power of the arduino.
SCHEMATICS
This is how the motor driver is connected to arduino, the GND on the motor driver connects to the GND of arduino, 5V of the motor driver connects to the VIN on arduino to supply power. A battery source of 5V to 9V ‘s positive terminal is connected the 12+ terminal port and the battery ground is connected to the ground of the motor driver. Connect the two motor wires to the two-pin terminal block. Do for the other motor. At the positive terminal of the battery, you can fix a switch which will be used to control and the on and off state of the project.
Here is a fritzing diagram of how the components are connected to the arduino and motors.
During the coding, it must be ensured that a motor’s both directions are not declared HIGH at an instance. When that happens, the motor will be stationary, wondering which command to obey or refuse. At any time, only one direction of one motor is supposed to be HIGH.
int motor1clockwise=3; // motor one clockwise signal connected to pin 3 int motor1anticlockwise=4; //motor one anticlockwise signal connected to pin 4 int motor2clockwise=5; //motor two clockwise signal connected to pin 5 int motor2anticlockwise=6; // motor two anticlockwise signal connected to pin 6 void setup(){ Serial.begin(9600); // declare all motor pins as OUTPUTS pinMode(motor1clockwise,OUTPUT); pinMode(motor1anticlockwise,OUTPUT); pinMode(motor2clockwise,OUTPUT); pinMode(motor2anticlockwise,OUTPUT); } void loop(){ digitalWrite(motor1clockwise,HIGH); //move motor one clockwise delay(1000); digitalWrite(motor1clockwise,LOW); //stop motor one clockwise digitalWrite(motor1anticlockwise,HIGH); //move motor one anticlockwise delay(1000); digitalWrite(motor1anticlockwise,LOW); //stop motor one anticlockwise digitalWrite(motor2clockwise,HIGH); //move motor two clockwise delay(1000); digitalWrite(motor2clockwise,LOW); // stop motor two clockwise digitalWrite(motor2anticlockwise,HIGH); //move motor two anticlockwise delay(1000); digitalWrite(motor2anticlockwise,LOW); // stop motor two anticlockwise }
Here is the complete assembly of the circuitary that is controlling two motors and causing them to move anticlockwise and clockwise in turns every second.
COMMENTS
ABOUT US
This is the tutorials website for Invent Electronics. We are a top online retailer of electronics components, microcontrollers and sensors in Ghana. Besides providing customers with good quality electronic components we want to help them build great projects with the components they buy for us so we’ve put together a ton electronics resources, projects and tutorials on this site just for you!
Looking for electronic components to buy in Ghana?
Get all your sensors, electronic components, Arduinos, Raspberry Pi and other parts for your project at great prices from our online store.
Join Our Community
We’re more than just an electronics store. We are also a community of makers, engineers, enthusiasts and more. Join our community today, meet and learn from other people like you.