Introduction: Control DC Motor Using L293D

Picture of Control DC Motor Using L293D

Hello everyone,

In this instructable we will be controlling DC motor using L293D and Arduino.

The L293D motor driver is able to control the speed as well as direction of motor.

Step 1: Gather the Parts

Picture of Gather the Parts

For, controlling DC motor using L293D we will need:

  • An Arduino UNO
  • A L293D motor driver
  • Small DC motor
  • A Breadboard
  • Jumper wire pack

Step 2: Circuit

Picture of Circuit

Hookup all the components according to the circuit shown above.

Pins on L293D :

  • The speed of the motor is controlled by Enable 2 pin using analogWrite() function.
  • While the direction of the motor is controlled by In 3 and In 4 pins.

Step 3: Arduino Sketch

Picture of Arduino Sketch

Upload the following code to Arduino using Arduino IDE

int enable2 = 9;

int in3 = 10;

int in4 = 11;

void setup()

{

pinMode(enable2, OUTPUT);

pinMode(in3, OUTPUT);

pinMode(in4, OUTPUT);

}

void loop()

{

analogWrite(enable2, 200); // Any value between 0 and 255

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

delay(10000);

analogWrite(enable2, 200); // Any value between 0 and 255

digitalWrite(in3, LOW);

digitalWrite(in4, HIGH);

delay(10000);

}

To control the direction of the motor :

  • The pins in3 and in4 must be set to opposite values.
  • If in3 is HIGH and in4 is LOW, the motor will spin one way, on the other hand in3 is HIGH and in4 LOW then, the motor will spin in the opposite direction.

To control the speed of the motor :

  • The speed is set by using an analogWrite to the enable pin.
  • Speed of the motor can be changed by changing the value in "analogWrite", The motor spins at a maximum speed if the value in analogWrite is set as 255.

Step 4: Done

Picture of Done

Now just power the Arduino using USB or 9V battery and see your motor spinning.

Thanks for viewing.

Comments

prakhar_42 made it! (author)2017-06-05

Hey guys it a very good circuit to start with, but do add one more connection between Arduino Vin and pin 8 of IC.

geostarspais (author)prakhar_422017-10-21

Additional clarification: If you only want the maximum voltage going to the motor(s) to be 5 volts, then connect the Arduino 5V pin to pin 8 of the L293D motor controller. If you want the maximum volts (4.5 to 36) to the motor(s) to be the same as the power supply, then connect the Arduino Vin pin to pin 8 of the L293D motor controller. Make sure the motor(s) are rated for the voltage of the power supply and keep the max current draw to less than 500mA to 600mA per channel, or else things will burn out.


About This Instructable

3,570views

23favorites

License:

Bio: So, I got a bunch of LEDs when I was 8 or 9 something.
More by Anshu AR:Scratch Built RC AirplaneH Bridge Motor Driver For Arduino Using TransistorsHow To Use A Piezo To Produce Tone : Basics
Add instructable to: