How to Get Started with L293D Motor Driver Shield with Arduino

Introduction

I have here an L293D Motor Driver Shield V1. It has 2 pieces L293D dual H-bridge motor driver IC to be able to provide control to a total of 4 DC motor. It also comes with 74HC595 shift registers to minimized the use of pins.

Pin Assignment

DC Motors:
Motor 1: digital pin 11
Motor 2: digital pin 3
Motor 3: digital pin 5
Motor 4: digital pin 6

Servo Motors:
Servo 1: digital pin 9
Servo 2: digital pin 10

Shift registers:
Digital pins 4, 7, 8, and 12

Hardware Serial:
Digital pins 0 and 1

Not Connected:
Digital pins 2 and 13
Analog A0 to A5

How to use L293D Motor Driver Shield:
It can run up to 4 DC Motors in bidirectional turns
Use terminal block M1 for motor 1
Use terminal block M2 for motor 2
Use terminal block M3 for motor 3
Use terminal block M4 for motor 4

It can run 2 stepper motors (unipolar and bipolar)
Use terminal block M1 and M2 for stepper 1
Use terminal block M3 and M4 for stepper 2

It can run 2 servo motors using the 3-pin male headers.

How to supply power to the shield:

  1. Single power supply for both Arduino and motors:
    Coonect AC-to-DC power adapter to Arduino DC barrel jack
    Connect external DC power supply to the EXT_PWR terminal block
    This setup take advantage of the onboard voltage regulator found in the Arduino Uno board.
    Make sure that the PWR jumper pin is in place

  2. Separate power supply for Arduino and for motors:
    Power the Arduino through the USB or through the DC barrel connector
    Power the motors through the EXT_PWR terminal block
    Make sure that the PWR jumper pins is removed. You might damaged your Arduino if you accidentally forget this step.

Others:
Onboard pull down resistor array to keep the motors switch OFF during power up
Onboard power LED indicator.
Onboard reset switch button

Video Demonstration

Source Code

 1
 2// Adafruit Motor shield library
 3// copyright Adafruit Industries LLC, 2009
 4// this code is public domain, enjoy!
 5
 6#include "AFMotor.h"
 7
 8AF_DCMotor motor(1);
 9
10void setup() {
11  Serial.begin(9600);           // set up Serial library at 9600 bps
12  Serial.println("Motor test!");
13
14  // turn on motor
15  motor.setSpeed(200);
16  motor.run(RELEASE);
17}
18
19void loop() {
20  uint8_t i;
21  Serial.print("tick");
22  motor.run(FORWARD);
23  for (i = 0; i < 255; i++) {
24    motor.setSpeed(i);  
25    delay(10);
26 }
27  for (i = 255; i != 0; i--) {
28    motor.setSpeed(i);  
29    delay(10);
30 }
31  
32  Serial.print("tock");
33  motor.run(BACKWARD);
34  for (i = 0; i < 255; i++) {
35    motor.setSpeed(i);  
36    delay(10);
37 }
38 
39  for (i = 255; i != 0; i--) {
40    motor.setSpeed(i);  
41    delay(10);
42 }
43  Serial.print("tech");
44  motor.run(RELEASE);
45  delay(1000);
46}

Call To Action

That’s all for now. If you have any questions or clarifications, please write it in the comments section.

Thank you and have a good day.



Posts in this series



No comments yet!

GitHub-flavored Markdown & a sane subset of HTML is supported.