DC Motor Control with L293D Motor Driver

Dual H-Bridge Motor Driver for DC or Steppers - 600mA - L293D

This is a very useful chip. It can actually control one motor independently. We will use in its entirety the chip in this tutorial. Pins on the right hand side of the chip are for controlling a one motor. Pins on the left hand side of the chip are for controlling second motor.

You can run four solenoids, two DC motors or one bi-polar or uni-polar stepper with up to 600mA per channel using the L293D.



Each chip contains two full H-bridges (four half H-bridges). That means you can drive four solenoids, two DC motors bi-directionally, or one stepper motor. Just make sure they're good for under 600 mA since that's the limit of this chip. They do handle a peak of 1.2A but that's just for a short amount of time. What we like most about this particular driver is that it comes with built in kick-back diodes internally so you dont have to worry about the inductive kick damaging your project or driver

There's a PWM input per driver so you can control motor speed. Runs at 5V logic. Good for motor voltages from 4.5V up to 36V! This wont work well for 3V motors. The motor voltage is separate from the logic voltage.

The L293D has two +V pins (8 and 16). The pin '+Vmotor (8) provides the power for the motors, and +V (16) for the chip's logic.

Normally we can connect both of these to the Arduino 5V pin. We used a powerful motor, or a higher voltage motor. So we provided the motor with a separate power supply using pin 8 connected to the positive power supply and the ground of the second power supply is connected to the ground of the Arduino.


Hardware Required:

- Arduino
- Dual H-Bridge Motor Driver
- DC Motors
- Breadboard
- Wires
- Batteries

Recommended site to buy the required hardware:

Get the Code:
const int leftForward = 2;
const int leftBackward = 3;
const int rightForward = 4;
const int rightBackward = 5;

void setup() 
  pinMode(leftForward , OUTPUT);
  pinMode(leftBackward , OUTPUT);
  pinMode(rightForward , OUTPUT);
  pinMode(rightBackward , OUTPUT);


void loop()
  digitalWrite(leftForward , HIGH);
  digitalWrite(leftBackward , LOW);
  digitalWrite(rightForward , HIGH);
  digitalWrite(rightBackward , LOW);