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

SOIL MOISTURE SENSOR USING ARDUINO WITH CONNECTION AND CODE

SOIL MOISTURE SENSOR USING ARDUINO WITH CONNECTION AND CODE Soil moisture sensor is the sensing element which determine the volumetric amount of water in the soil .The sensor sense the amount of water by passing an minute voltage at its terminal .Then when the water presence is detected it send an minute voltage to the amplifying circuit and it is further amplified and send to the Arduino. Components Required:                       1) Arduino                       2) Soil Moisture sensor                       3) Led                       4) Connecting wires...

India Space Research

INDIAN SPACE RESEARCH                                      The Technology is developing day by day and new innovations are coming out day by day. Many things are runs with help of satellites for example TV receiver, Weather Forecasting, Global positioning systems(GPS), Defense purposes. Thus Aerospace development is very important for an country. INDIA , places 5 th place in space developments. The ISRO is the Indian organization of space research Developments. What is ISRO? ISRO expands as Indian Space Research Organization, which is the Indian space Development organization. ISRO Ranks 5 th place in space research. Who founded ISRO?  Indian Space Research Organization (ISRO) was founded by Jawaharlal Nehru, who is the First Prime Minister of INDIA and Scientist Vikram Sarabhai, who is known as the father of space programs in the year 1962 as Indian National Com...

How does ant walk in straight line

How does ant walk in straight line? Normally, Ants live as big colony and it is organized. When the ant found food it takes a small piece of food and returns to its colony, while returning from the food area to its colony ant releases chemical called pheromones with the help of pheromones  other ants in their colony goes to the food area and brings the food to their colony. The pheromones evaporates at certain time of interval so other ants which carry food also releases pheromones it helps in reaching of other ants from colony to reach food. Every each set of ant consists of unique set of pheromones so it helps to find other colony and its does not allow other colony ant to enter in their colony and even it attacks them. How does old book smell good? Smell of book is basically by the paper and ink and the paper is primarily made up of wood and the wood is made up of cellulose and lignin . Over years, the book is exposed to heat, light, moisture and it bega...