Project tutorial
Obstacle Avoiding Robot

Obstacle Avoiding Robot

Have you ever seen a vacuum cleaner robot? Have you been wondering what was its main functionality? Then check out this tutorial!

  • 126 views
  • 1 comment
  • 1 respect

Components and supplies

Necessary tools and machines

Apps and online services

About this project

In the previous tutorial, I've been explaining the basics about L298N Motor Driver, let's see how much it's useful in robotics.

When we build/design a robotic system we need to make sure we get 5 essential things straight :

First,The Task & the functionality, in our example the task is vacuuming and the functionality required in order to reach the task properly is avoiding obstacles so let's focus on this functionality and get it done properly.

Second, The Parameter at the input and the sensor responsible about collecting it's data, we need to make sure we know which parameter is involved and then we need to purchase the adequate sensor to collect it's data, in our example the parameter required is the obstacle and the adequate sensor is an ultrasonic range finder that I've already explained it's basics on my first tutorial.

Third, the brain ! after collecting data there's a need for data processing, choosing the optimal brain technology for that is kinda tricky sometimes, in our case we only need a micro-controller to perform one task like an arduino uno !

Fourth, the actuators at the output, in our case it's clearly Motors, after processing the data collected by the micro-controller from the sensor, it's time that the micro-controller order the actuators to " make a move " and that's depends on when we programmers decided to ! isn't a great job to be a programmer ?!

Fifth , Power !!! and that's will lead us to read datasheets in order to calculate how much voltage we need and in which form is suitable, in our case a 9V battery is suitable regarding the voltage drop of L298N and arduino uno, i've already explained the working of L298N in one of my previous tutorials.

Finally, all the things above need to be on the Chassis of the robot ! so get your hands dirty a little !

Code

Obstacle_avoiding.inoArduino
int trigPin = 9;      // trig pin of HC-SR04
int echoPin = 10;     // Echo pin of HC-SR04

int revleft4 = 4;       //REVerse motion of Left motor
int fwdleft5 = 5;       //ForWarD motion of Left motor
int revright6 = 6;      //REVerse motion of Right motor
int fwdright7 = 7;      //ForWarD motion of Right motor

long duration, distance;

void setup() {
  
  delay(random(500,2000));   // delay for random time
  Serial.begin(9600);
  pinMode(revleft4, OUTPUT);      // set Motor pins as output
  pinMode(fwdleft5, OUTPUT);
  pinMode(revright6, OUTPUT);
  pinMode(fwdright7, OUTPUT);
  
  pinMode(trigPin, OUTPUT);         // set trig pin as output
  pinMode(echoPin, INPUT);          //set echo pin as input to capture reflected waves
}

void loop() {

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);   
  digitalWrite(trigPin, HIGH);     // send waves for 10 us
  delayMicroseconds(10);
  duration = pulseIn(echoPin, HIGH); // receive reflected waves
  distance = duration / 58.2;   // convert to distance
  delay(10);
    // If you dont get proper movements of your robot then alter the pin numbers
  if (distance > 19)            
  {
    digitalWrite(fwdright7, HIGH);                    // move forward
    digitalWrite(revright6, LOW);
    digitalWrite(fwdleft5, HIGH);                                
    digitalWrite(revleft4, LOW);                                                       
  }

  if (distance < 18)
  {
    digitalWrite(fwdright7, LOW);  //Stop                
    digitalWrite(revright6, LOW);
    digitalWrite(fwdleft5, LOW);                                
    digitalWrite(revleft4, LOW);
    delay(500);
    digitalWrite(fwdright7, LOW);      //movebackword         
    digitalWrite(revright6, HIGH);
    digitalWrite(fwdleft5, LOW);                                
    digitalWrite(revleft4, HIGH);
    delay(500);
    digitalWrite(fwdright7, LOW);  //Stop                
    digitalWrite(revright6, LOW);
    digitalWrite(fwdleft5, LOW);                                
    digitalWrite(revleft4, LOW);  
    delay(100);  
    digitalWrite(fwdright7, HIGH);       
    digitalWrite(revright6, LOW);   
    digitalWrite(revleft4, LOW);                                 
    digitalWrite(fwdleft5, LOW);  
    delay(500);
  }

}

Custom parts and enclosures

Components Required
Airbrush 20191111195437 oce5eufgdq

Schematics

Connections
New bitmap image (3) idcysejmbl

Comments

Similar projects you might like

Project 1: 2WD Obstacle Avoiding Robot

Project showcase by HDA Robotics

  • 31,223 views
  • 14 comments
  • 39 respects

Ground-Based Obstacle Avoiding Robot

Project showcase by Xavier Tan

  • 10,325 views
  • 2 comments
  • 30 respects

Obstacle Avoiding Robot Using Microcontroller (Arduino)

Project tutorial by Aarav Garg

  • 4,872 views
  • 0 comments
  • 15 respects

3D-Printed Arduino Obstacle Avoiding Robot

Project tutorial by Arnov Sharma

  • 3,079 views
  • 0 comments
  • 4 respects

Obstacle Avoiding Robot Car

Project showcase by Aritra_B

  • 5,413 views
  • 4 comments
  • 23 respects
Add projectSign up / Login