Control DC Motor Using L293D

25,817

30

7

Introduction: 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

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

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

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

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

Thanks for viewing.

Makerspace Contest

Participated in the
Makerspace Contest

Maker Olympics Contest 2016

Participated in the
Maker Olympics Contest 2016

1 Person Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

7 Discussions

0
MuhammadL42
MuhammadL42

1 year ago

Sir, can we select the value of speed in points ?

0
VedantD4
VedantD4

2 years ago

Is this circuit applicable for 12v motor as well?

1
Anshu AR
Anshu AR

Reply 2 years ago

Yes,

As per the datasheet of the L293D motor driver, it says that it can operate from 4.5V to 36V.

But, it can provide a maximum of 600mA output current. (per channel). So, check how much current will the motor draw. The motor should not draw current more than 600mA at any instance.

0
VedantD4
VedantD4

Reply 2 years ago

Also, can I know which software you have used to make the two circuit diagrams? Thank you.

0
usamaabro
usamaabro

Question 2 years ago on Introduction

my aurdino ide software is not uploading program

0
Anshu AR
Anshu AR

Answer 2 years ago

Hi usamaabro,
That's quite unlikely to happen.
Anyways you can always copy and paste the sketch that's included in step 3.
Or, you can post a screenshot of the error that's being displayed on your Arduino IDE.