Introduction: Arduino Controlled L293D Robot ( Part 1 - Update 1.0 )

Here is part 1 of the Arduino and L293D Robot.This is part of a series of instructables leading to a Line follower Robot.

This is a basic Robot made by controlling two motors via the L293D chip through an Arduino Board.

I have done this project in the past with similar set up just not with an Arduino Board.

Do let me know what you think of this project and if I made any mistakes.

Step 1: Parts

Arduino Board

Breadboard

L293D Chip

Two Motors

9 Volt Battery

6 Volt Battery Pack

Step 2: Wiring the L293D Chip

Pin 4 ,Pin 5,Pin 12 and Pin 13 from L293D Chip Connect to Ground (Negative On Breadboard)

Pin 1,Pin 9 and Pin 16 from L293D Chip Connect to 5 Volts (Positive On Breadboard)

Pin 8 from L293D Chip Connects to 6 Volts (Positive Lead of Battery Pack)

Pin 3 from L293D Chip Connects to Right Motor
Pin 6 from L293D Chip Connects to Right Motor

Pin 11 from L293D Chip Connects to Left Motor
Pin 14 from L293D Chip Connects to Left Motor

Output pins on Arduino to control Right Motor :
Pin 2 from L293D Chip Connects to Output Pin on Arduino
Pin 7 from L293D Chip Connects to Output Pin on Arduino

Output pins on Arduino to control Left Motor :
Pin 10 from L293D Chip Connects to Output Pin on Arduino
Pin 15 from L293D Chip Connects to Output Pin on Arduino





Step 3:

Step 4: Connecting the Motors to L293D Chip

Pin 3 from L293D Chip Connects to Right Motor
Pin 6 from L293D Chip Connects to Right Motor

Pin 11 from L293D Chip Connects to Left Motor
Pin 14 from L293D Chip Connects to Left Motor

Step 5: Connecting the Pins to 5 Volts and Ground

Pin 4 ,Pin 5,Pin 12 and Pin 13 from L293D Chip Connect to Ground (Negative On Breadboard)

Pin 1,Pin 9 and Pin 16 from L293D Chip Connect to 5 Volts (Positive On Breadboard)

Pin 8 from L293D Chip Connects to 6 Volts (Positive On Breadboard)

Step 6: Output Pins on Arduino to Control the Motors

Output pins on Arduino to control Right Motor :

Pin 2 from L293D Chip Connects to Output Pin on Arduino
Pin 7 from L293D Chip Connects to Output Pin on Arduino

Output pins on Arduino to control Left Motor :

Pin 10 from L293D Chip Connects to Output Pin on Arduino
Pin 15 from L293D Chip Connects to Output Pin on Arduino

Step 7: Power

9 Volts powering the Arduino Board

6 Volts(4 Double A 1.5 Volts batteries) connected to the Breadboard powering the motors.

Step 8: Basic Code to Go Straight

// The following is the basic Arduino code which runs a loop that makes the Robot go straight forward.


int LeftMotorForward = 10; // Pin 10 has Left Motor connected on Arduino boards.
int LeftMotorReverse = 9; // Pin 9 has Left Motor connected on Arduino boards.

int RightMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.
int RightMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards.


void setup()
{
  pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.
}

// The following Loop is to make the Robot go staright
void loop()

{
   digitalWrite(RightMotorForward, HIGH);   // turn the Right Motor ON
   digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ON
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
}

Step 9: Basic Code to Go Right

int LeftMotorForward = 10; // Pin 10 has Left Motor connected on Arduino boards.
int LeftMotorReverse = 9; // Pin 9 has Left Motor connected on Arduino boards.

int RightMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.
int RightMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards.


void setup()
{
  pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.
}

// The following Loop is to make the Robot go Right
void loop()

{
   digitalWrite(RightMotorForward, LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ON
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
}

Step 10: Basic Code to Go Left

int LeftMotorForward = 10; // Pin 10 has Left Motor connected on Arduino boards.
int LeftMotorReverse = 9; // Pin 9 has Left Motor connected on Arduino boards.

int RightMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.
int RightMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards.


void setup()
{
  pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.
}

// The following Loop is to make the Robot go Left
void loop()

{
   digitalWrite(RightMotorForward, HIGH);   // turn the Right Motor ON
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
}

Step 11: Basic Code to Reverse

int LeftMotorForward = 10; // Pin 10 has Left Motor connected on Arduino boards.
int LeftMotorReverse = 9; // Pin 9 has Left Motor connected on Arduino boards.

int RightMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.
int RightMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards.


void setup()
{
  pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.
}

// The following Loop is to make the Robot Reverse
void loop()

{
   digitalWrite(RightMotorReverse, HIGH);   // turn the Right Motor ON
   digitalWrite(LeftMotorReverse, HIGH);   // turn the Left Motor ON
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
}

Step 12: Code to Make Robot Go Forward,Right,Left,Reverse and Stop All in a Loop

int LeftMotorForward = 10; // Pin 10 has Left Motor connected on Arduino boards.
int LeftMotorReverse = 9; // Pin 9 has Left Motor connected on Arduino boards.

int RightMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.
int RightMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards.

//-----------------------------------------------------------------------------  
void setup()
{
  pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.
  pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.
  pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.
}
//-----------------------------------------------------------------------------  

// The following Loop is to make the Robot go staright
void loop()
{
   void Driveforward();
  
   digitalWrite(RightMotorForward, HIGH);   // turn the Right Motor ON
   digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ON
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
//-----------------------------------------------------------------------------  
   void Rightturn();
  
   digitalWrite(RightMotorForward, LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ON
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for 10 seconds
//-----------------------------------------------------------------------------  
   void Leftturn();
  
   digitalWrite(RightMotorForward, HIGH);   // turn the Right Motor ON
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);               // wait for  10 seconds
 
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);   // wait for  10 seconds
//-----------------------------------------------------------------------------  
   void Reverse();
  
   digitalWrite(RightMotorReverse, HIGH);   // turn the Right Motor ON
   digitalWrite(LeftMotorReverse, HIGH);   // turn the Left Motor ON
   delay(10000);               // wait for a 10 seconds
 
   digitalWrite(RightMotorReverse, LOW);   // turn the Right Motor ON
   digitalWrite(LeftMotorReverse, LOW);   // turn the Left Motor ON
   delay(10000);               // wait for a 10 seconds
//----------------------------------------------------------------------------- 

   void Allstop();
  
   digitalWrite(RightMotorReverse, LOW);   // turn the Right Motor ON
   digitalWrite(LeftMotorReverse, LOW);   // turn the Left Motor ON
   delay(10000);               // wait for  10 seconds
  
   digitalWrite(RightMotorForward,LOW);   // turn the Right Motor OFF
   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF
   delay(10000);    // wait for  10 seconds
//----------------------------------------------------------------------------- 
}

Comments

author
NIkheel94 made it! (author)2015-05-12

My apologies if i haven't been answering any Question.
I have been really busy with school and haven't had a chance to get back to instructables. During the next few weeks and summer months i will try to answer all questions and help with any issues you may have. I will also Update this instructables and make a better and more detailed version.

Thank you for your patience, Feedback and support.
I greatly appreciate it

Once again i am sorry if i wasnt able to help you.

author
MSFrdsR made it! (author)MSFrdsR2017-02-05

can help me ?

author
MSFrdsR made it! (author)2017-02-05

can you make toturial using this ? make toturial how to set up it for controlled robot

ToInstructables.png
author
Bayu AdrianA made it! (author)2017-01-30

hello i have problem the code "int LeftMotorForward = 10;" error so I copy to code the up why erorr please help me

author
rrawat2 made it! (author)2014-09-01

int IN1=13;

int IN2=12;

int IN3=11;

int IN4=10;

void setup()

{

pinMode(IN1,OUTPUT);

digitalWrite(IN1,LOW);

pinMode(IN2,OUTPUT);

digitalWrite(IN2,LOW);

pinMode(IN3,OUTPUT);

digitalWrite(IN3,LOW);

pinMode(IN4,OUTPUT);

digitalWrite(IN4,LOW);

Serial.begin(9600);

}

void loop()

{

if(Serial.available()>0)

{

char letter=Serial.read();

if(letter=='8') //forward moving robot

{

digitalWrite(IN1,HIGH);

digitalWrite(IN2,LOW);

digitalWrite(IN3,HIGH);

digitalWrite(IN4,LOW);

Serial.println("THE ROBOT WILL MOVE FORWARD");

}

else if(letter=='5') //STOP ROBOT

{

digitalWrite(IN1,LOW);

digitalWrite(IN2,LOW);

digitalWrite(IN3,LOW);

digitalWrite(IN4,LOW);

Serial.println("THE ROBOT WILL BE STOP");

}

else if(letter=='2') //REVERSE ROBOT

{

digitalWrite(IN1,LOW);

digitalWrite(IN2,HIGH);

digitalWrite(IN3,LOW);

digitalWrite(IN4,HIGH);

Serial.println("THE ROBOT WILL MOVE REVERSE");

}

else if(letter=='4') //LEFT ROBOT

{

digitalWrite(IN1,HIGH);

digitalWrite(IN2,LOW);

digitalWrite(IN3,LOW);

digitalWrite(IN4,HIGH);

Serial.println("THE ROBOT WILL MOVE LEFT");

}

else if(letter=='6') //RIGHT MOVING ROBOT

{

digitalWrite(IN1,LOW);

digitalWrite(IN2,HIGH);

digitalWrite(IN3,HIGH);

digitalWrite(IN4,LOW);

Serial.println("THE ROBOT WILL MOVE RIGHT");

}

}

}

//this is move on by keyboard button so try and enjoy

author
shivamt7 made it! (author)shivamt72016-01-30

hey why you'v given datatype as char letter and value as int. and what does letter signify.

author
shivamt7 made it! (author)shivamt72016-01-30

hey why you'v given datatype as char letter and value as int. and what does letter signify.

author
navneet kaur made it! (author)2015-03-22

can we incorporate IR sensor in this project, if yes then what changes are required?

author
NIkheel94 made it! (author)NIkheel942015-05-12

Here is Part 2 where i did add IR to the Project
https://www.instructables.com/id/Arduino-and-L293D-Robot-Part-2-Infrared-Sensor/

author
shivamt7 made it! (author)shivamt72016-01-30

hey can we move in all 4 directions i.e including backwards

author
NIkheel94 made it! (author)NIkheel942015-05-12

You wouldn't have to make any physical changes, only to the code.
Just add the IR sensor to the Arduino and connect it to the Digital pins if i am not mistaken.
I have been really busy with school. If you are not in a rush i can make a complete version with IR and get back to you in the next few weeks.

author
robbinscientist made it! (author)2015-11-05

hi sir i want to make this without a bread board

author
Pruthi made it! (author)2015-10-12

I'm using an 11v battery for this will i need to use a diode and transistor to control the voltage being carried to the arduino?

author
techno man made it! (author)2015-06-27

Amaizing ......

One of the easiest,low cost and simplest arduino robot project in the web

Thank you sir for this awesome project
Waiting for more projects like this

author
Harrylorence made it! (author)2015-06-21

Cool man your explanation is simple and great..do more instructables..waiting for thae next one..

author
faizi.barcaboy made it! (author)2015-01-28

Thanks Alot! It Works I am so Happy (Y)

author
NIkheel94 made it! (author)NIkheel942015-05-26

I am happy that i was able to make you happy.

author
yhdesai made it! (author)2015-02-01

MAKE A SHIELD OF L293D MOTOR CONTROLLER

author
NIkheel94 made it! (author)NIkheel942015-05-26

Is that a Suggestion or a Request ?
I'll probably design a schematic one day and make my own at home.

author
Ramasubramanian Aditya made it! (author)2015-02-01

Thank You Very Much! You explained the concept very clearly in comparison to other instructables, and it worked!!!!!

author
NIkheel94 made it! (author)NIkheel942015-05-26

Thank you. I am glad it worked for you.

author
ICareP made it! (author)2015-05-11

great work, i hope it works. Can you pls post a schematics image using fritzing

author
NIkheel94 made it! (author)NIkheel942015-05-12

I never head of fritzing before and unfortunately i have been really busy with school and life.
I will try my best to make a detailed schematic using fritzing as soon as possible.
Thank you for your patience.

author
ICareP made it! (author)ICareP2015-05-13

yh, fritzing is open-source and free http://fritzing.org/download/ and it allows you to draw schematics and creates pcb layouts form those schematics. I'm also busy w/ school and life, I couldn't see clearly the images posted, I'm building a robot etoy prototype for anyone we're on kickstarter already you can spread the word, or back us to http://kck.st/1D7lOtk cheers

author
rudy.hengeveld made it! (author)2014-12-21

thanks a lot..it works...Mars here we come

author
maljundi made it! (author)2014-12-06

hi.. i want to get l293d ic but i think it's need (heat sink) !!

so plz.. explain y u didn't use heat sink and really it's need it ??!

author
sai instruct made it! (author)2014-10-23

wat happens wen 9V is given to enable pins

author
rrawat2 made it! (author)2014-09-01

input 1 of l293d ic will connect on arduino13 pin.

input 2 of l293d ic will connect on arduino12 pin.

input 3 of l293d ic will connect on arduino10 pin.

input 4 of l293d ic will connect on arduino 9 pin.

and make the circuit by using this circuit diagram and code will available below.(rrawat2)

l293d-based-motor-driver.png
author
tisaconundrum made it! (author)2014-04-09

So I figured out how to get it wired correctly. All the batteries need to be grounded together.

Untitled picture.png
author
tisaconundrum made it! (author)tisaconundrum2014-04-09

Edit: I had the batteries connected to the wrong pins. I was testing and the motor wasn't even running. So here is the correct schemtaic

Untitled picture.png
author
tisaconundrum made it! (author)2014-04-09

Now where does the ground for the 5 V battery go?

Untitled picture.png
author
asarkar9 made it! (author)2014-03-12

Do we have to convert a program written in C++ to machine language, in order to make ARDUINO UNO work? If yes, then how to do it? And can you please give a link for downloading the software required for ARDUINO? Please reply ASAP.... it's very important. Thanks.

author
skant1 made it! (author)skant12014-04-05

NO WE DON'T HAVE TO CONVERT THE CODE TO ASSEMBLY(IT IS ACTUALLY AN ADVANTAGE WITH ARDUINO).....PROGRAMMING ARDUINO IS VERY VERY SIMPLE...GO TO www.arduino.cc AND DOWNLOAD THE ARDUINO ZIP FOLDER

then open zip folder and save it to desktop and connect your arduino board to usb port using usb cable and open device manager and find your arduino in ports section and right click on it and click update driver and choose from pc then open arduino folder saved in desktop and choose drivers that is it....your arduino is connected and then do hardware as per above given and program the arduino using arduino application and upload it....you are done

author
paras11 made it! (author)2014-02-27

hey i tried to follow d steps but my l293d gets really heated
can u tell me why is this happening???
:O

author
beginner13 made it! (author)2013-12-11

wat r the output pins for arduino,where do i connect the pin2,pin7,pin10 and pin15 to arduino

author
Haitham khedr made it! (author)2013-10-24

Hello, i am trying to drive a dc motor with L293D ,i supply 5 volts to pin 8 and when i measure the output voltage it is reduced to 2.6 volt when i connect the motor only,if the motor is not connected all the input is transfered to the output . Would you please help solving this problem?

Thanks

author
Haitham khedr made it! (author)2013-10-24

Hello, i am drive a dc motor with L293D ,i supply 5 volts to pin 8 and when i measure the output voltage it is reduced to 2.6 volt when i connect the motor only,if the motor is not connected all the input is transfered to the output . Would you please help solving this problem?

Thanks

author
Vee20 made it! (author)2013-09-28

Hi there. Lovely instructable! Is there any way to slow down the speed of the motor? I find that it moves a bit too fast for my intended purpose. Thank you!

author
NIkheel94 made it! (author)NIkheel942013-09-28

Try the following to see if it works,if it doesn't i will have to test it to figure it out.

Option 1 :

delay(10000); // waits for 10 seconds
This line will keep the motor on for 10 seconds.

delay(1000); // waits for a second
This line will keep the motor on for 1 second.

By adjusting the amounts of seconds you adjust the amount of time the motor stays on and this can be used to slow down turns.

Option 2 :

To slow down the motor try the following command.
The following is an Example for the Right Motor Only.
Follow the same structure for other motors you want to control.

Replace the command

digitalWrite(RightMotorForward, HIGH);

with

analogWrite(RightMotorForward,N);

Let "N" be any number between 0 and 255, 0 is stop and 255 is the Highest speed.

Example: analogWrite(RightMotorForward,155);


This is a modification of the fade example from the Arduino Library.
Hope This Helps.

author
Vee20 made it! (author)Vee202013-10-12

thank you. will try it out and get back to you :)

author
mgarg5 made it! (author)2013-10-09

Does the motor need to have a feedback? I have a DC motor. Can i use it using this method.
Regards.
And i do hope you rspond fast . i need to et this done by this weekend :)

author
NIkheel94 made it! (author)NIkheel942013-10-09

No this project does not require Feed Back as it does not rely on sensory feedback to control movement. This project is based on predetermined preprogrammed commands. You can however edit the code to fit your needs.

Yes this Project can be done with a DC motor. A DC Motor can be controlled through the application of Voltage change and can be made to turn slower or faster.

Follow through the Steps and carefully read the instructions while using the images as aid and you should be fine.

author
cdragos george made it! (author)2013-06-29

A wonderful guide to start working with Arduino Uno. As you can see I add a link in my article  where is an impressive collection of guides and tutorials to start working with Uno.

author
NIkheel94 made it! (author)NIkheel942013-09-28

Thanks for including my project.

author
volt107 made it! (author)2013-06-07

Thanks a lot for this tutorial man. This is probably the clearest and simplest arduino robot tutorial on the web! Got mine to work. Thanks again.

author
NIkheel94 made it! (author)NIkheel942013-09-28

Glad you Liked it.
Thanks.

author
NIkheel94 made it! (author)NIkheel942013-06-10

Thanks.
I think it could have been of better Quality but Thanks again.

author
ajimzack made it! (author)2013-06-15

my project has been done...this is the link video..thanks,,http://www.youtube.com/watch?v=v2Y_s3R8EOY&feature=youtu.be

author
NIkheel94 made it! (author)NIkheel942013-09-28

Looks Good.
Good Job.

author
volt107 made it! (author)2013-06-05

Also, how are pins 1, 9, 16 connected to 5V? I just see them connected to negative on the breadboard.