Introduction: Using Motors With L293D IC

Picture of Using Motors With L293D IC

This is a quick guide with a bit of extra info (pin configurations etc..) that I’ve learnt along the way on how to use the L293D with the Arduino, showing that we can:
A) Use a supplemental power source to power the DC motor.

B) Use the L293D chip to drive the motor.

From microcontroller we can not connect a motor directly because microcontroller can not give sufficient current to drive the DC motors. Motor driver is a current enhancing device, it can also be act as Switching Device. Thus we insert motor driver in between motor and microcontroller.

Motor driver take the input signals from microcontroller and generate corresponding output for motor.

Motor Driver IC L293D

This is a motor driver IC that can drive two motor simultaneously. L293D IC is a dual H-bridge motor driver IC. One H-bridge is capable to drive a dc motor in bidirectional. L293D IC is a current enhancing IC as the output from the sensor is not able to drive motors itself so L293D is used for this purpose. L293D is a 16 pin IC having two enables pins which should always be remain high to enable both the H-bridges.

Step 1: L293D DC Motor Driver & Pin Configuration

Picture of L293D DC Motor Driver & Pin Configuration

“The L293D is a monolithic integrated, high voltage, high current, 4-channel driver.” Basically this means using this chip you can use DC motors and power supplies of up to 36 Volts, thats some pretty big motors and the chip can supply a maximum current of 600mA per channel, the L293D chip is also what’s known as a type of H-Bridge. The H-Bridge is typically an electrical circuit that enables a voltage to be applied across a load in either direction to an output, e.g. motor.

This means you can essentially reverse the direction of current and thus reverse the direction of the motor. It works by having 4 elements in the circuit commonly known as corners: high side left, high side right, low side right, and low side left. By using combinations of these you are able to start, stop and reverse the current. You could make this circuit out of relays but its easier to use an IC – The L293D chip is pretty much 2 H-Bridge circuits, 1 per side of the chip or 1 per motor.

The bit we really care about in all of this is the 2 input pins per motor that do this logic and these, more importantly for our needs, can be controlled from the Arduino board.

You also don’t have to worry about voltage regulation so much because it allows for 2 power sources – 1 direct source, upto 36V for the motors and the other, 5V, to control the IC which can be supplied from the Arduino power supply or since my motor power supply is only 6V I’m going to use this (if the motor supply was higher I would consider using a transistor or voltage regulator). The only thing to remember is that the grounding connection must be shared/ common for both supplies. Below you can see the pin layout for the chip and the truth table showing the output logic.

L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors.

L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation, two DC motors can be driven simultaneously, both in forward and reverse direction. The motor operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and anticlockwise directions, respectively.

Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start operating. When an enable input is high, the associated driver gets enabled. As a result, the outputs become active and work in phase with their inputs. Similarly, when the enable input is low, that driver is disabled, and their outputs are off and in the high-impedance state.

Pin Configuration:

  1. Enables and disables the motor whether it is on or off (high or low)
  2. Logic pin for the motor (input is either high or low)
  3. Is for one of the motor terminals can be either +/-
  4. Ground
  5. Ground
  6. Is for the other motor terminal
  7. Logic pin for our motor (input is either high or low)
  8. Power supply for the motor
  9. Enables and disables the 2nd motor on or off (high or low)
  10. Logic pin for the 2nd motor (input is either high or low)
  11. Is for one of the 2nd motor terminals can be either +/-
  12. Ground
  13. Ground
  14. Is for the 2nd motors other terminal
  15. Logic pin for the 2nd motor (input is either high or low)
  16. Connected to +5V,

Step 2: DC MOTORS AND DC STEPPER MOTORS

Picture of DC MOTORS AND DC STEPPER MOTORS

Electrical motors are everywhere around us. Almost all the electro-mechanical movements we see around us are caused either by a AC or a DC motor. Here we will be exploring DC motors. This is a device that converts DC electrical energy to a mechanical energy.

Step 3: THE ELECTRONIC:

Picture of THE ELECTRONIC:
  • ARDUINO UNO
  • L293D IC
  • BREADBOARD
  • JUMPER WIRES
  • 9V BATTERY

Step 4: FOR DC MOTORS

Picture of FOR DC MOTORS

USING GEARED DC MOTORS OR SIMPLE DC MOTORS:


Arduino Code:
// Use this code to test your motor with the Arduino board:

#define E1 10 // Enable Pin for motor 1
#define E2 11 // Enable Pin for motor 2 #define I1 8 // Control pin 1 for motor 1 #define I2 9 // Control pin 2 for motor 1 #define I3 12 // Control pin 1 for motor 2 #define I4 13 // Control pin 2 for motor 2 void setup() { pinMode(E1, OUTPUT); pinMode(E2, OUTPUT); pinMode(I1, OUTPUT); pinMode(I2, OUTPUT); pinMode(I3, OUTPUT); pinMode(I4, OUTPUT); } void loop() { analogWrite(E1, 153); // Run in half speed analogWrite(E2, 255); // Run in full speed digitalWrite(I1, HIGH); digitalWrite(I2, LOW); digitalWrite(I3, HIGH); digitalWrite(I4, LOW); delay(10000); // change direction digitalWrite(E1, LOW); digitalWrite(E2, LOW); delay(200); analogWrite(E1, 255); // Run in full speed analogWrite(E2, 153); // Run in half speed digitalWrite(I1, LOW); digitalWrite(I2, HIGH); digitalWrite(I3, LOW); digitalWrite(I4, HIGH); delay(10000); }

Step 5: FOR DC STEPPERS MOTORS

Picture of FOR DC STEPPERS MOTORS

Stepper motors are DC motors that move in discrete steps. They have multiple coils that are organized in groups called "phases". By energizing each phase in sequence, the motor will rotate, one step at a time.

Two-phase stepper motors:

  • Unipolar motors
  • Bipolar motors

Here I'm using Bipolar stepper:

Arduino Code:
// Use this code to test your motor with the Arduino board:

int motorPin1 = 9;
int motorPin2 = 10; int motorPin3 = 11; int motorPin4 = 12; int delayTime = 50;

void setup() { pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); pinMode(motorPin3, OUTPUT); pinMode(motorPin4, OUTPUT); }

void loop() { digitalWrite(motorPin4, HIGH); digitalWrite(motorPin3, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin1, LOW); delay(delayTime);

digitalWrite(motorPin4, LOW); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin1, LOW); delay(delayTime);

digitalWrite(motorPin4, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin1, LOW); delay(delayTime);

digitalWrite(motorPin4, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin1, HIGH); delay(delayTime); }

Step 6: USING THE SERVO - DOESN'T REQUIRE L239D IC (ADDITIONAL)

Picture of USING THE SERVO - DOESN'T REQUIRE L239D IC  (ADDITIONAL)

It is tiny and lightweight with high output power. This servo can rotate

approximately 180 degrees (90 in each direction), and works just like the standard kinds but smaller. You can use any servo code, hardware or library to control these servos.

Hardware connections:

thee SG90 micro servo motor has 3 wire interface in which the connections should made as follows:

  • Red wire-5V
  • Brown wire-Ground
  • Yellow wire-digital pin 0

Arduino Code:

// Use this code to test your motor with the Arduino board:

#include<servo.h>  // Include the Servo library #include  

int servoPin = 0; // Declare the Servo pin
Servo Servo1; // Create a servo object
void setup() { // We need to attach the servo to the used pin number Servo1.attach(servoPin); } void loop() { // Make servo go to 0 degrees Servo1.write(0); delay(1000); // Make servo go to 90 degrees Servo1.write(90); delay(1000); // Make servo go to 180 degrees Servo1.write(180); delay(1000); }

Comments

Nounou 2016 (author)2017-11-08

Thanks !!!

tthiagoaraujo made it! (author)2017-11-08

I made it using the Tinkercad enviroment. https://www.tinkercad.com/things/ab0BaKT8ajI-glorious-gaaris-robo/editel?tenant=circuits?sharecode=APUjnnxIqgVMRZ_h97eWE7jAZfMshC3c9Y4XdRlr5xI=

chingada (author)2017-11-07

nice material yo be part of a electronic class thanks

Maggie Shah (author)chingada2017-11-08

Thank you

Chuckwilcox (author)2017-11-07

Thank you for the good explanation about the IC and the motors interesting. This knowledge will come in handy in the future. Thanks for sharing.

Maggie Shah (author)Chuckwilcox2017-11-08

I appreciate.

fabelizer (author)2017-11-07

Appears to be some corrections to the part numbers needed. L293D in some places, L239D in others. I think you probably mean for them to be consistent.

Maggie Shah (author)fabelizer2017-11-08

I've corrected them. Thank you

About This Instructable

9,327views

194favorites

License:

More by Maggie Shah:CUT THE CORD: DIY Qi WIRELESS CHARGING PAD AND STAND. Using Motors With L293D ICPortable Bluetooth Speaker With Built-In PowerBank
Add instructable to: