How to Use the L293D Motor Driver - Arduino Tutorial

146,769

265

37

About: Arduino Tutorials by Codebender.cc Team

Intro: How to Use the L293D Motor Driver - Arduino Tutorial

The L293D is a 16-pin Motor Driver IC which can control a set of two DC motors simultaneously in any direction. The L293D is designed to provide bidirectional drive currents of up to 600 mA (per channel) at voltages from 4.5 V to 36 V (at pin 8!). You can use it to control small dc motors - toy motors. Sometimes it can be extremely hot.

In this tutorial you will learn how to use it with Arduino uno to control two dc motors.

Step 1: What You Will Need

For this project you will need:

  • Arduino uno
  • Breadboard
  • L293D Motor Driver IC
  • 2x (small) DC motors

Step 2: The Circuit

The connections are easy, see the image above with the breadboard circuit schematic.

Tip: You can connect an external power source to L293D pin 8, up to 36V! Make sure not to "burn" your motors!

Step 3: The Code

Here's the code, embedded using codebender!

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board!


You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code. For example try to combine parts of code to move both motors simultaneously.

Try to use analogWrite(pin, PWM value) instead digitalWrite(pin, HIGH/LOW) to control the speed of motors!

Step 4: Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use the L293D motor driver IC to control two dc motors with the Arduino uno board.

I hope you liked this, let me know in the comments.
There will be more of them, so make sure to click Follow button!

Share

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Audio Contest 2018

    Audio Contest 2018
  • Fix It! Contest

    Fix It! Contest

37 Discussions

0
None
chandrajit_choudhary

8 months ago

Can I control the motors in both the directions using non PWM i/o terminals on the arduino uno

1 reply
0
None

You can either use Digital output (High/Low) from arduino to go ON/Off to control the moto, and you can go further and apply PWM (need a PWM out + Digital out) to control speed. Digital turns on the motor in the direction you want and PWM tells at what speed.

0
None
merengueleWindnsails

Answer 12 days ago

Yes, you only have to look for pin equivalence. Remember that the number of the pins are not the same as the name of the ports. Ex: pin number 27 can be D10 (writing by memory). And you put in your code the pin number, not the port.

0
None
merenguelevicwealth

Answer 12 days ago

Look that there are 4 motor wires, 2 by each motor. When turning in one direction you put HIGH and LOW (ex: pin1: HIGH, pin2: LOW) and the other direction the reverse (ex: pin1: LOW, pin2: HIGH). Never HIGH,HIGH.

Notice that LOW/LOW: Is a stoped motor.

0
None
RashmiP12

Question 5 months ago

Can I use three 100 rpm BO motor to connect with L293d?
Why L293d is required to interface BO motor to arduino, how much current required for BO motor and supplied by arduino.?

1 more answer
0
None
RahulS556RashmiP12

Answer 2 months ago

Hiii,

The following Code is for creating the robot with 2 DC motors.

const int motorPin1 = 5;

const int motorPin2 = 6;

const int motorPin3 = 7;

const int motorPin4 = 8;

void setup(){

//Set pins as outputs

pinMode(motorPin1, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

pinMode(motorPin4, OUTPUT);

}

void loop()

{

digitalWrite(motorPin1, HIGH);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, LOW);

delay(2000);

digitalWrite(motorPin1, LOW);

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, HIGH);

delay(2000);

}

0
None
Sk130

Question 6 months ago

Can I use four 100 rpm BO motor with L293 motor driver .
And how much input voltage is required for motor driver

0
None
naimulislam19149

Question 7 months ago on Introduction

I am new to electronics and I am not understanding exactly, why I need to use a motor controller IC? Can't I use my arduino only to run a DC motor?

0
None
S.S4

1 year ago

Hi. Can I have 4 time more current consumption (4*600 mA) from L293D to a DC motor with just one direction by using parallel circuit of input's and output's of the this H-bridge IC ? (as shown in picture)

Untitled.jpg
3 replies
0
None
S.S4S.S4

Reply 1 year ago

so , because no body answered me quickly, I decide to make this idea myself, and I succeed . by this method you can reach up to 2400 mA from all of four H-bridge's of one L293D, also if you solder 1, 2 or 3 IC's on top of together you can reach multple current's depend number of IC's.

good luck.

0
None
jwzumwaltS.S4

Reply 10 months ago

Perhaps a better option is to use the L293 (no 'D') which is rated at 1amp per output.

0
None
Arduino12345

10 months ago

u can use 4017 ic instead of arduino

0
None
RohitT13

1 year ago

Hey, there is an error when displaying the code from https://codebender.cc/. Please fix this error soon or provide the code snippet some other way. That would be really helpful.

0
None
cia-21

2 years ago

Hey, can I make a variable speed driver with L293D?

1 reply
0
None
PramêshB1cia-21

Reply 1 year ago

Yeah, using analogwrite instead of digitalwrite & assigning values