Arduino Controlled L293D Robot ( Part 1 - Update 1.0 )

181,066

82

60

Intro: 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
//----------------------------------------------------------------------------- 
}

Share

Recommendations

  • Electronics Tips & Tricks Challenge

    Electronics Tips & Tricks Challenge
  • Audio Contest 2018

    Audio Contest 2018
  • Plastics Contest

    Plastics Contest

60 Discussions

0
None
NIkheel94

3 years ago on Introduction

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.

1 reply
0
None
ekeked

Question 2 months ago on Step 8

For the code that makes the robot go straight, why must we use delay() ? And why must we use digitalWrite() to put the pin as LOW, why not letting both the forward pin as HIGH ?

0
None
Bayu AdrianA

1 year ago

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

0
None
rrawat2

4 years ago on Introduction

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

2 replies
0
None
shivamt7rrawat2

Reply 2 years ago

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

0
None
shivamt7rrawat2

Reply 2 years ago

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

0
None
NIkheel94navneet kaur

Reply 3 years ago on Introduction

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/

0
None
shivamt7NIkheel94

Reply 2 years ago

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

0
None
NIkheel94navneet kaur

Reply 3 years ago on Introduction

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.

0
None
robbinscientist

2 years ago

hi sir i want to make this without a bread board

0
None
Pruthi

3 years ago

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?

0
None
techno man

3 years ago

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

0
None
Harrylorence

3 years ago

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

0
None
NIkheel94yhdesai

Reply 3 years ago on Introduction

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

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