L293D Motor Driver Shield & Arduino

L293D Motor Driver Shield and Arduino:
When you are planning and assembling your new robot, you will eventually want to learn about controlling variety of motors like DC motors, Stepper motors and servos. One of the easiest and inexpensive way to do that is to interface L293D Motor Driver Shield with Arduino. It’s a full-featured motor shield–perfect for many robot and CNC projects.
It can drive:
1. 4 bi-directional DC motors with 8-bit speed selection(0-255).
2. 2 stepper motors (unipolar or bipolar) with single coil, double coil, interleaved or micro-stepping.
3. 2 servo motors.

L293D Motor Driver and 74HC595 Shift Register:
The L293D is a dual-channel H-Bridge motor driver capable of driving a pair of DC motors or single stepper motor.
As the shield comes with two L293D motor driver chipsets, that means it can individually drive up to four DC motors making it ideal for building four-wheel robot platforms.

The shield offers total 4 H-Bridges and each H-bridge can deliver up to 0.6A to the motor.
The shield also comes with a 74HC595 shift register that extends 4 digital pins of the Arduino to the 8 direction control pins of two L293D chips.

Power Supply:
Three types supplying power for the motors through shield.

Single DC power supply for both Arduino and motors:
If you would like to have a single DC power supply for both Arduino and motors, simply plug it into the DC jack on the Arduino or the 2-pin EXT_PWR block on the shield. Place the power jumper on the motor shield. You can employ this method only when motor supply voltage is less than 12V.

(Recommended) Arduino powered through USB and motors through a DC power supply:
If you would like to have the Arduino powered off of USB and the motors powered off of a DC power supply, plug in the USB cable. Then connect the motor supply to the EXT_PWR block on the shield. Do not place the jumper on the shield.

Two separate DC power supplies for the Arduino and motors:
If you would like to have 2 separate DC power supplies for the Arduino and motors. Plug in the supply for the Arduino into the DC jack, and connect the motor supply to the EXT_PWR block. Make sure the jumper is removed from the motor shield.

The output channels of both the L293D chips are broken out to the edge of the shield with two 5-pin screw terminals viz. M1, M2, M3 & M4. You can connect four DC motors having voltages between 4.5 to 25V to these terminals.
Each channel on the module can deliver up to 600mA to the DC motor. However, the amount of current supplied to the motor depends on system’s power supply.
You can also connect two stepper motors to output terminals. One stepper motor to motor port M1-M2 and other to M3-M4. The GND terminal is also provided if you happen to have a unipolar stepper motor. You can connect the center taps of both stepper motors to this terminal. The shield brings out the 16bit PWM output lines to two 3-pin headers to which you can connect two servo motors.
Installing AFMotor Library:
In order to communicate with the shield, we need to install AFMotor.h library so that we can issue simple commands to control DC, stepper & servo motors.
To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.

ARDUINO CODE FOR DC MOTOR SHIELD:

#include<AFMotor.h>
AF_DCMotor motor(4);
void setup()
{
//Set initial speed of the motor and stop
motor.setSpeed(200);
motor.run(RELEASE);
}
void loop()
{
uint8_t i;
// Turn on motor
motor.run(FORWARD);
// Accelerate from zero to maximum speed
for (i=0; i<255; i++)
{
motor.setSpeed(i);
delay(10);
}
// Decelerate from maximum speed to zero
for (i=255; i!=0; i--)
{
motor.setSpeed(i);
delay(10);
}
// Now change motor direction
motor.run(BACKWARD);
// Accelerate from zero to maximum speed
for (i=0; i<255; i++)
{
motor.setSpeed(i);
delay(10);
}
// Decelerate from maximum speed to zero
for (i=255; i!=0; i--)
{
motor.setSpeed(i);
delay(10);
}
// Now turn off motor
motor.run(RELEASE);
delay(1000);
}
Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 504

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×