Project tutorial
Obstacle Avoiding Robot

Obstacle Avoiding Robot

A simple obstacle avoiding robot developed on Arduino platform.

  • 1,247 views
  • 0 comments
  • 4 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
09670 01
SparkFun Dual H-Bridge motor drivers L298
×1
51gzz5eu9pl. sx425
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Battery - 18650 - 7800mAh- 3.7V
×1
56t2029 40
Battery Holder, 18650 x 2
×1
Tens70
9V battery (generic)
×1
Adafruit industries ada80 image 75px
9V to Barrel Jack Connector
×1
BO Motor - Straight - 300rpm
×1
11026 02
Jumper wires (generic)
×1
Ball Caster Wheel
×1
Chasis - Eg. Plastic Box Cover, Acrylic Sheet, Metal Sheet
×1
4314603
Toggle Switch, (Off)-On
×1

Necessary tools and machines

Apps and online services

About this project

  • Step 1: Assemble the circuit as shown in the schematic given below. You can use the battery pack for powering driver circuit which I have mentioned in the components section or you could try out some other battery pack, but keep it mind it should deliver between 7-12V and atleast 3500mAh. Also, use different battery/battery-packs for powering Arduino and the Motor-Driver module, but ensure they share a common ground. Battery is one of the most important thing in this project !
  • Step 2: Compile the code given below in the Arduino-IDE and hit upload.
  • Step 3: Now you have gone through all the hard work ! Turn on the toggle switch and watch the robot avoiding obstacles !



Code

Obstacle Avoiding RobotC/C++
Download/Copy-Paste and compile+upload it using Arduino IDE.
int trigPin = 9;      // Trig Pin Of HC-SR04
int echoPin = 8;     // Echo Pin Of HC-SR04
int revleft4 = 10; // Motor Pins
int fwdleft5 = 11;
int revright6 = 12;
int fwdright7 = 13;
long duration, distance;

void setup() {
  Serial.begin(9600);
  pinMode(revleft4, OUTPUT); // Set Motor Pins As O/P
  pinMode(fwdleft5, OUTPUT);
  pinMode(revright6, OUTPUT);
  pinMode(fwdright7, OUTPUT);
  pinMode(trigPin, OUTPUT); // Set Trig Pin As O/P To Transmit Waves
  pinMode(echoPin, INPUT); //Set Echo Pin As I/P To Recieve Reflected Waves
}

void loop() {

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);   
  digitalWrite(trigPin, HIGH); // Transmit Waves For 10us
  delayMicroseconds(10);
  duration = pulseIn(echoPin, HIGH); // Recieve Reflected Waves
  distance = duration / 58.2; // Get Distance
  delay(10);
  if (distance > 20) // Condition For Absence Of Obstacle            
  {
    digitalWrite(fwdright7, HIGH); // Move Forward
    digitalWrite(revright6, LOW);
    digitalWrite(fwdleft5, HIGH);                                
    digitalWrite(revleft4, LOW);                                                       
  }

  if (distance < 20) // Condition For Presence Of Obstacle
  {
    digitalWrite(fwdright7, LOW); //Stop                
    digitalWrite(revright6, LOW);
    digitalWrite(fwdleft5, LOW);                                
    digitalWrite(revleft4, LOW);
    delay(500);
    digitalWrite(fwdright7, LOW); // Move Backward             
    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); // Move Left       
    digitalWrite(revright6, LOW);   
    digitalWrite(revleft4, LOW);                                 
    digitalWrite(fwdleft5, LOW);  
    delay(500);
  }

}

Schematics

Obstacle Avoiding Robot
Connect them and get going !
Capture wn98sxou5m

Comments

Similar projects you might like

Project 1: 2WD Obstacle Avoiding Robot

Project showcase by HDA Robotics

  • 35,079 views
  • 16 comments
  • 41 respects

Ground-Based Obstacle Avoiding Robot

Project showcase by Xavier Tan

  • 12,195 views
  • 2 comments
  • 34 respects

3D-Printed Arduino Obstacle Avoiding Robot

Project tutorial by Arnov Sharma

  • 3,913 views
  • 0 comments
  • 5 respects

Obstacles Avoiding Robot With Servo Motor

Project tutorial by Sora JY

  • 13,252 views
  • 3 comments
  • 30 respects

Obstacle Avoiding Car

Project showcase by Team Adam

  • 36,509 views
  • 5 comments
  • 50 respects
Add projectSign up / Login