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

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...

Top 5 Expensive Cars in the World

5) Bugatti Veyron The Bugatti Veyron is a mid Engine sports car designed and developed by Volkswagen group and manufactured in Molsheim , France . The Top speed of the Bugatti Veyron is 407 km/h and it has 7 Speed direct Shift Automatic Transmission. The Designer of Bugatti Veyron is Jozef Kaban. The Price of Bugatti Veyron is approximately $1.7 million (Rs 12 crore). 4) Aston Martin Valkyrie The Aston Martin Valkyrie is manufactured by Aston Martin and it is the limited production of hybrid electric sports car. The maximum speed of Aston Martin Valkyrie is 402 km/h and it has a 7 speed Ricardo dual clutch transmission. The designer of Aston Martin Valkyrie is Adrian Newey. The price of Aston Martin Valkyrie is approximately $3.2 million (Rs 22 crore). 3) Lamborghini Veneno Roadstar The Lamborghini Veneno Roadstar is manufactured by Lamborghini and only 9 units of Lamborghini Veneno Roadstar were and 8 of them were sold and 1 remained at the facto...

Ice Bergs Melt due to Carbon dioxide

Ice Bergs Melt due to Carbon dioxide What is CO2?                                  CO2 which is expanded has Carbon dioxide . The CO2 in atmosphere is 0.04 and present in Earth Atmosphere. The CO2 is basically an Green House Gas which plays in important role in Maintaining Earth Average Temperature of 57 degrees Fahrenheit . The CO2 is basically an heat trapping effective green house gas. It does not trap all gas molecule on IR radiations and it also remits the IR radiations during night where other else earth average temperature will be 0 degrees Fahrenheit . Any how not only CO2 all green house gases plays an important role in it. How CO2 produced?                              CO2 is given naturally by respiration and deforestation and Main r...