L293D Motor Driver
Why do we use l293d?
Hey, Welcome to the make it much tutorials point.It’s the 4th one in the series of Arduino Learn by Doing projects series.So Today we will learn about how to use a motor Shield with Arduino. How to drive the motor with the motor driver.And How to use L293d motor driver module/shield with Arduino.
I have used this shield for making a remote control robot that I will show to at the end.We can easily control 4 motors with this driver module.Before moving towards the detailed study and use about l293d Module read these posts about:
Why we use Motor driver
Contents:
- Introduction to L293D motor shield
- L293D motor shield Pinout Configuration
- Components List for L293d motor shield
- Arduino Code for L293d Motor driver Shield
Introduction to L293D Motor Shield
L293D is a Motor driver IC used to control motors with a microcontroller. This motor shield consists of three IC’s. We can control 4 motors with the shield so there are two L293d Ic’s used. The motor shield is used for (Arduino Uno) board.This shield can control servo’s, Dc motors and stepper motors.
The two chips of L293D can control four motors with 0.6 A per bridge. The best thing about the shield is we don’t need to write the whole function for driving a motor there is a special library for this module.we just recall some commands to run the motor.
L293D Motor Shield Pinout Configuration
Here is the Pinout Configuration of the Module. Install the shield first on Arduino board and check everything that works fine. The four pins for Dc motors on Left and Right side. We can also connect stepper motors on these pins.
The Motor driver shield comes with 600 mA per motor and 1.2 A peak current.
The motors can be controlled from 4v to 25 volts.
Components List
- Arduino Uno Board
- Adafruit motor shield
- Jumper wires
- DC or stepper motors
Install the Library From this Link:
Download L293d Motor Shield Library
https://github.com/adafruit/Adafruit-Motor-Shield-library/zipball/master
Arduino Code
When you install the library there will be different codes available in the library for controlling motors. Include the desired library in the code.
Here is the testing code for DC motors. The testing code is also available for servo and stepper motors.
In the library, we don’t need to define anything everything has already been defined. Just call the function Forward the motor will start working forward.Same for reverse and so on.
We can set the speed of the motor using command setSpeed(speed).The speed will be from 0-255.
We can also use this command for separated functions.In the testing code, the same speed is set for four motors.
#include <AFMotor.h> AF_DCMotor motor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm void setup() { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Motor test!"); motor.setSpeed(200); // set the speed to 200/255 } void loop() { Serial.print("tick"); motor.run(FORWARD); // turn it on going forward delay(1000); Serial.print("tock"); motor.run(BACKWARD); // the other way delay(1000); Serial.print("tack"); motor.run(RELEASE); // stopped delay(1000); }
Test the Code and Connections.If you found any problem using the motor shield then comment below.
Using only the Module for driving motor like L298N is rather easier but we need to define each and everything where we connect motor pins on Arduino and which pins are used for Enable to control the speed.Somehow it is easier.
Read the Next post on How to make a Remote control Robot/CAR with L293D module.
Here is the picture of an upcoming post about Remote control Robot.
Comment below if you have any query and Subscribe to our YouTube Channel for Video tutorials.