Skip to main content

OBSTACLE AVOIDANCE CAR

                          OBSTACLE AVOIDANCE CAR

                        The obstacle avoidance car is just basically which overcome the obsctacles comes in front it.It avoid obstacle with help of the ultrasonic sensor and changes the direction.


Components Required:

                          

                           1)Arduino
                           2)Ultrasonic sensor
                           3)Motor Shield
                           4)Motors
                           5)Chassis kit
                           6)Connecting wires

Connection:

                Ultrasonic  = Arduino

                      +vcc = +5v
                       Gnd = Gnd
                      Trig  = A1
                      Echo = A2
                      Light = A0


Procedure:

               Insert Motor shield to Arduino and next connect the ultrasonic sensor as shown as per above connection and connect the led to A0 pin and next connect the Motors the Motor Shield.Now just copy the code and paste it on Arduino.The distance of ultrasonic could be defined.

   delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;// convert the distance to centimeters.
  if (distance < 25)/*if there's an obstacle 25 centimers, ahead, do the following: */ {        
       
   u can set as u want in 25 as your wish

Source code:


#include <AFMotor.h> //NBSL COMMERCIAL
#

#define trigPin A1
#define echoPin A2
AF_DCMotor motor1(1,MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_8KHZ);

void setup() {
  Serial.begin(9600); // begin serial communitication 
  Serial.println("Motor test!");
   pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
  pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
  motor1.setSpeed(255); //set the speed of the motors, between 0-255
motor2.setSpeed (255); 
}

 void loop()
{
  pinMode(A0, OUTPUT);//for Led
   long duration, distance; // start the scan
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2); // delays are required for a succesful sensor operation.
  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;// convert the distance to centimeters.
  if (distance < 25)/*if there's an obstacle 25 centimers, ahead, do the following: */ {

   digitalWrite(A0, HIGH);  //for Led
  delay(50);                     
  digitalWrite(A0, LOW);   
  delay(50); 
  digitalWrite(A0, HIGH); 
  delay(50); 
   digitalWrite(A0, LOW);   
  delay(50);
digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50);
  digitalWrite(A0, HIGH); 
  delay(50);
  digitalWrite(A0, LOW); 
  delay(50); 
   Serial.println ("Close Obstacle detected!" );
Serial.println ("Obstacle Details:");
Serial.print ("Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!");// print out the distance in centimeters.
Serial.println (" The obstacle is declared a threat due to close distance. ");
Serial.println (" Turning !");
 motor1.run(BACKWARD); //if there's no obstacle ahead, Go Forward!
    motor2.run(FORWARD);

}
  else {
   Serial.println ("No obstacle detected. going forward");
   delay (15);;
     motor1.run(FORWARD);  // Turn as long as there's an obstacle ahead.
    motor2.run (FORWARD);
    
  }

}



Lets Check How it Work:


                                            POWERED BY

                                                   NBSL

Comments

Popular posts from this blog

What if you could control the Internet

At present situation internet is the basic need for us, we are using the internet for many purposes from medicine to aerospace internet is used and helps in day to day life activates. Internet is spread out in all the areas and we could say it is the most powerful tool in the world, if you got a chance to control the internet what will you do.                                                Image Credit : Internet In general, more than 5 billion google searches are done all over the world and millions of hours videos are watches in facebook and YouTube daily. What if you got a chance to control the internet, whether it is possible to control the internet, the internet is actually controlled with the help of 7 keys and by 14 peoples all around the world. They maintain the DNS which helps in accessing the internet all around the world. The DNS helps in accessing ...

Creating Artificial Planet

Already our Earth is loosing the habitable tendency due to the deforestation, Climate changes, etc. These all causes our Earth as inhabitable planet, for life better we should move into another planet to move into another planet we could create our own planet. But, it is possible to build a planet as like Earth with Atmosphere, Air, Water, Moderate Temperature, Gravity, etc. Theoretically, it is said we could build a planet like Earth. We could build our own planet right in our solar system for constant temperature as we get in our planet “Earth”. We could probably use asteroids in our solar system to build our artificial planet, but we are having only lower amount of asteroids in our solar system so we cannot build a planet as we expected so we are going to use OORT CLOUD to build our Artificial Planet but problem with this OORT CLOUD is it is so far from our Earth, we haven’t still invented that fast vehicle to bring that materials here, so this case could not help us. We have ...

Nasa Spacecraft OSIRIS-REX arrives at ancient asteroid Bennu

What is OSIRIS-REX?            OSIRIS-REX is a man-made artificial satellite which was launched on 8 th September 2016 from Cape Canaveral Air force station. OSIRIS-REX is launched to take samples from the ancient asteroid Bennu and it is estimated to return Earth on 2023. What is Bennu Asteroid?             Bennu was discovered on 11 th September 1999 by Lincoln-Near Earth Asteroid research . The Bennu asteroid is 492 meter wide and it has a mass of 78 billion kilogram. Scientist estimated Bennu could pass closer to Earth than moon in 2135, which close distance of 250,000 miles. What is OSIRIS-REX Work?              The OSIRIS-REX is send to take samples from the Asteroid Bennu to help scientist understand how heat radiated from sun is gently steering Bennu on increasing menacing course through solar system. The OS...