Featured

Search

How to use L293d Module motor shield with Arduino

how to use motor driver with arduino motor shield with arduino


Hey...Welcome to the make it mech tutorials point.Its the 4th one in the series of Arduino Learn by Doing projects series.Today we will learn about how to use a motor Shield with arduino. How to drive the motor with motor driver.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 control 4 motors with this module.Before moving towards the detail study and use about l293d Module read these posts about Why we use Motor driver and How to Control DC motors with L293d IC

Contents:

  1. Introduction to L293D motor shield
  2. L293D motor shield Pinout Configuration
  3. Components List
  4. Arduino Code

1-Introduction to L293D Motor Shield

L293D is a Motor driver IC used to control motors with 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 shield is used for arduino Uno board.This shield can control  servo's , Dc motors and stepper motors.The 2 L293D chips 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.
The shield is created by Adafriut so you can read more specifications about the motor shield on adafruit website. 

how to use motor driver with arduino


2-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. There are four pins for Dc motors on Left and Right side. We can also connect stepper motors on these pins. 

arduino tutorials how to use l293d module , pinout configuration of l298 module

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 volt.


3-Components List

  • Arduino Uno Board 
  • Adafruit motor shield
  • jumper wires
  • DC or stepper motors

Install the Library From this Link:


4-Arduino Code

When you install the library there will be different codes available in the the library for controlling motors. Include the 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 motor using command setSpeed(speed) .The speed will be from 0-255.
We can also use this command for seperate functions.In the 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 motor shield then comment below.
Using only the Module for driving motor like L298N  is rather more easy 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 more easy.
Read the Next post on How to make a Remote control Robot/CAR with L293D module.
Here is the picture of Remote control Robot .

arduino tutorials with complete  codes

Previous
Next Post »

Featured