What Is the L293D Motor Driver?
The L293D is a popular H-bridge motor driver IC that allows you to control the speed and direction of up to two DC motors simultaneously.
Pinout of the L293D
- Enable Pins: EN1 and EN2 (Enable motor channels)
- Input Pins: IN1–IN4 (Control motor direction)
- Output Pins: OUT1–OUT4 (Connect motors)
- VCC1: Logic voltage (5V)
- VCC2: Motor voltage (5V–36V)
Arduino Example Code
#define EN1 9
#define IN1 8
#define IN2 7
void setup() {
pinMode(EN1, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
}
void loop() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(EN1, 128);
delay(2000);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
analogWrite(EN1, 128);
delay(2000);
}