The L293D Motor Driver Shield is an Arduino-compatible motor control shield that uses the L293D integrated circuit (IC) to control the direction and speed of motors, particularly DC motors and stepper motors. It is a popular choice for beginners and hobbyists in robotics and automation projects due to its ease of use and integration with Arduino boards.
Key Features of the L293D Motor Driver Shield:
- Motor Control:
- Can control 2 DC motors (or 1 stepper motor).
- Each motor can be controlled for forward, reverse, or brake modes.
- Supports PWM for motor speed control.
- L293D IC:
- The L293D is a quad H-bridge IC that can drive two DC motors simultaneously.
- It can handle motor voltages from 4.5V to 36V and provides up to 600mA per motor, with peak currents of 1.2A.
- It also features built-in diodes for back EMF protection, which are crucial for protecting the IC when motors are suddenly stopped.
- Arduino Compatibility:
- The L293D Motor Driver Shield is designed to stack directly on top of an Arduino (or compatible) board, such as Arduino Uno, Mega, or Nano.
- It provides a set of pins that connect directly to the Arduino's digital I/O pins to control the motor’s direction and speed.
- External Power Supply:
- The motors are powered by an external power supply (typically 5V-12V), while the Arduino board itself powers the logic circuits (5V).
- Speed Control:
- The shield allows motor speed control through PWM (Pulse Width Modulation), which is done by providing a PWM signal to the Enable pins of the L293D IC.
- Easy Pinout:
- The shield exposes motor control pins and the power supply pins, making it easy to wire up and control motors from the Arduino.
Basic Pinout of the L293D Motor Driver Shield:
Pin Function Description:-
IN1, IN2 Motor A Direction Used to control the direction of Motor A
IN3, IN4 Motor B Direction Used to control the direction of Motor B
ENA, ENB Enable Pins Control the speed of motors A and B via PWM (PWM pin)
VCC Motor Power Connect to external power supply (5V to 12V)
GND Ground Ground connection for both Arduino and motor power
OUT1, OUT2 Motor A Output Motor A terminals to be connected to the motor
OUT3, OUT4 Motor B Output Motor B terminals to be connected to the motor
Wiring Overview:
- Motor A (DC motor):
- OUT1 → Motor terminal 1
- OUT2 → Motor terminal 2
- IN1 → Control pin for forward/reverse
- IN2 → Control pin for forward/reverse
- ENA → PWM pin for speed control (can be connected to an Arduino PWM-capable pin like D3 or D5)
- Motor B (DC motor):
- OUT3 → Motor terminal 1
- OUT4 → Motor terminal 2
- IN3 → Control pin for forward/reverse
- IN4 → Control pin for forward/reverse
- ENB → PWM pin for speed control
- Power Supply:
- VCC → External power source (e.g., 9V battery, 12V DC adapter)
- GND → Common ground between Arduino and external power supply
Example Code for Controlling DC Motors:
// Define motor control pins
int motorPin1 = 3; // IN1
int motorPin2 = 4; // IN2
int enablePinA = 5; // ENA (PWM for speed control)
void setup() {
// Set motor pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePinA, OUTPUT);
}
void loop() {
// Move Motor A Forward
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
analogWrite(enablePinA, 255); // Set maximum speed (0-255)
delay(2000); // Run forward for 2 seconds
// Stop Motor A
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
analogWrite(enablePinA, 0); // Set speed to 0 (stop motor)
delay(2000); // Wait for 2 seconds
// Move Motor A Backward
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
analogWrite(enablePinA, 255); // Full speed backward
delay(2000); // Run backward for 2 seconds
}
Brand:- Generic
Origin:- China