Project tutorial
Make an Arduino-Based Edge Avoiding Robot

Make an Arduino-Based Edge Avoiding Robot © CC BY-SA

Let's make a fully autonomous robot using Arduino and IR sensors. It can explore the surface of a table without falling!

  • 4,234 views
  • 0 comments
  • 15 respects

Components and supplies

Apps and online services

About this project

Let's make a fully autonomous robot using Arduino and IR sensors. It can explore a table surface without falling. Watch video for more!

Components used:

  • Piece of cardboard
  • Arduino Uno
  • IR sensor
  • BO motor
  • Wheels
  • Caster wheel
  • L293d IC
  • PCB
  • Flexible wire
  • LED
  • 330R resistor
  • Battery
  • Connecters male/female
  • PCB terminal

Take a piece of cardboard of dimension 135mm x120mm. mark all dimensions as per given layout and cut it.

Stick all cut part using hot glue. Stick both motors on their place. Fit wheels to both motors. Place IR sensors in frontside of the robot body. Also fit two LED’s in front side. This LED’s are just for improving the look of robot you can skip this led if not available. Stick caster wheel in back side on bottom of robot body. Now place battery inside it. Keep maxweight in back side of robot. Close the upper side of body by sticking upper pre cut cardboard piece.

Now take PCB some male female connectors and H-Bridge L293D motor driver IC. Solder all components as per given circuit diagram. Connect both motor to motor driver Board which we recently soldered. Connect both sensors to the board. Now all connections are done.

Let’s upload the

//program by Shubham Shinganapure on 14-06-2019
//
//for Table Edge Avoiding Robot using IR sensors


int lm1=8; //left motor output 1
int lm2=9; //left motor output 2
int rm1=10; //right motor output 1
int rm2=11; //right motor output 2
int sl=13; //sensor 1 input (left)
int sr=12; //sensor 2 input (right)
int SlV=0;
int SrV=0;
int led=A0;
void setup()
{
pinMode(lm1,OUTPUT);
pinMode(lm2,OUTPUT);
pinMode(rm1,OUTPUT);
pinMode(rm2,OUTPUT);
pinMode(led,OUTPUT);
pinMode(sl,INPUT);
pinMode(sr,INPUT);
sTOP();
}
void loop()
{
SlV=digitalRead(sl);
SrV=digitalRead(sr);
if(SrV==LOW && SlV== LOW)
{
digitalWrite(led,LOW);
ForWard();
}
if(SrV==HIGH && SlV== HIGH)
{
digitalWrite(led,HIGH);
BackWard();
delay(400);
Right();
delay(550);
ForWard();
delay(200);
}
if(SrV==LOW && SlV== HIGH)
{
digitalWrite(led,HIGH);
BackWard();
delay(400);
Right();
delay(550);
ForWard();
delay(200);
}
if(SrV==HIGH && SlV== LOW)
{
digitalWrite(led,HIGH);
BackWard();
delay(400);
Left();
delay(550);
ForWard();
delay(200);
}
}
void ForWard()
{
digitalWrite(lm1,HIGH);
digitalWrite(lm2,LOW);
digitalWrite(rm1,HIGH);
digitalWrite(rm2,LOW);
}
void BackWard()
{
digitalWrite(lm1,LOW);
digitalWrite(lm2,HIGH);
digitalWrite(rm1,LOW);
digitalWrite(rm2,HIGH);
}
void Left()
{
digitalWrite(lm1,LOW);
digitalWrite(lm2,HIGH);
digitalWrite(rm1,HIGH);
digitalWrite(rm2,LOW);
}
void Right()
{
digitalWrite(lm1,HIGH);
digitalWrite(lm2,LOW);
digitalWrite(rm1,LOW);
digitalWrite(rm2,HIGH);
}
void sTOP()
{
digitalWrite(lm1,LOW);
digitalWrite(lm2,LOW);
digitalWrite(rm1,LOW);
digitalWrite(rm2,LOW);
}

Copy and pest code from here to Arduino IDE, connect Arduino board to your pc. SelectCOM port and board type from tool menu. And click upload.

After uploading program to Arduino, we all done, now let’s test it. Connect battery to Arduino. Here I’m using 2 lithium ion cell connected in series and wrap them together by using insulation tape, so the voltage of this battery is 7.4 volt. you can use 2s 7.4Volt lipo battery. Use supply voltage in between 6 to 9 volt.If you used higher voltage battery the speed of robot is higher and when it comes to edge it instantly apply break i.e. it revers it’s wheel rotation since it moving in higher speed the chance of falling is increases due to it’s forward inertia.



Hope you find this useful. if yes, like it, share it, comment your doubt. For more such projects, follow me! Support my Work and Subscribe to My Channel on YouTube.

Thank you!

Code

edge avoiding robotArduino
//program by Shubham Shinganapure on 14-06-2019
//
//for Table Edge Avoiding Robot using IR sensors  
  
  
int lm1=8; //left motor output 1
int lm2=9; //left motor output 2
int rm1=10;  //right motor output 1
int rm2=11;  //right motor output 2
int sl=13;    //sensor 1 input (left)
int sr=12;    //sensor 2 input (right)
int SlV=0;
int SrV=0;
int led=A0;
void setup()
{
 pinMode(lm1,OUTPUT);
 pinMode(lm2,OUTPUT);
 pinMode(rm1,OUTPUT);
 pinMode(rm2,OUTPUT);
 pinMode(led,OUTPUT);
 pinMode(sl,INPUT);
 pinMode(sr,INPUT);
sTOP();
}
void loop()
{
 SlV=digitalRead(sl);
 SrV=digitalRead(sr);
 if(SrV==LOW && SlV== LOW)
 {
   digitalWrite(led,LOW);
  ForWard();
   }
   if(SrV==HIGH && SlV== HIGH)
 {
   digitalWrite(led,HIGH);
  BackWard();
  delay(400);
  Right();
  delay(550);
  ForWard();
  delay(200);
   }
    if(SrV==LOW && SlV== HIGH)
 {
  digitalWrite(led,HIGH);
  BackWard();
  delay(400);
  Right();
  delay(550);
  ForWard();
  delay(200);
   }
    if(SrV==HIGH && SlV== LOW)
 {
  digitalWrite(led,HIGH);
  BackWard();
  delay(400);
  Left();
  delay(550);
  ForWard();
  delay(200);
   }
}
void ForWard()
 {
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,HIGH);
  digitalWrite(rm2,LOW);
 } 
 void BackWard()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,HIGH);
 }
 void Left()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  digitalWrite(rm1,HIGH);
  digitalWrite(rm2,LOW);
 } 
 void Right()
 {
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,HIGH);
 }  
   void sTOP()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,LOW);
 } 

Schematics

edge avoiding robot ckt
Uploads2ftmp2f5a3ad887 fadd 48b4 952c 4d532a1a0d2b2f0001sav28229 jo5hfecngb

Comments

Similar projects you might like

Line Follower Robot

Project tutorial by Shubham Shinganapure

  • 7,748 views
  • 3 comments
  • 19 respects

Make your first Arduino robot - The best beginners guide!

Project tutorial by Muhammed Azhar

  • 71,798 views
  • 19 comments
  • 155 respects

Amazing 6WD Off-Road Robot | Arduino RC Robot

Project tutorial by Jithin Sanal

  • 10,000 views
  • 0 comments
  • 54 respects

Project 1: 2WD Obstacle Avoiding Robot

Project showcase by HDA Robotics

  • 35,006 views
  • 16 comments
  • 41 respects

How to Make a Gesture Control Robot at Home

Project tutorial by Shubham Shinganapure

  • 10,397 views
  • 14 comments
  • 61 respects
Add projectSign up / Login