Object detection device

 



Materials required-:

  1. Arduino Uno
  2. Breadboard
  3. Jumper wires
  4. HC-SRO4 ultrasonic sensor
  5. LED or a Buzzer(as per your choice )
  6. 1k resistor

How It Works? 

Hello  ,
 
In this project I'm gonna show you ,how you can make a object detector  using HC-SRO4 sensor .
 The Ultrasonic Sensor works on the principle of 'echolocation'. The waves are generated from the transducer(Sensor trig pin ) using the Arduino and then reflect back after striking an object and then received by   receiver( Sensor Echo pin). The Ultrasonic sensor can detect up to 4m . Now, we have to set the limited distance at which we want  Digital Pin(13,12,11,10,......)  to go high   and we use this in giving digital(1,0) signal to a "LED" or " BUZZER" .




How To Connect?

Connection is very simple ,First of all you have to connect the sensor to Arduino .
i.e-:

VCC     pin to   +5volts
TRIG    pin to   DigitalPin(11)
ECHO  pin to    DigitalPin(12)
GND    pin to    GND

Circuit Diagram



Arduino Code


// defines pins numbers
int trigPin = 11;
int echoPin = 12;
int ledPin = 13;

//define variables
long duration;
int distance;
int Indication;

void setup() {
 pinMode(trigPin,OUTPUT);
 pinMode(echoPin,INPUT);
 pinMode(ledPin,OUTPUT);
Serial.begin(9600);   
   }

void loop() {
  
  
  //clears the trig pin 
digitalWrite(trigPin,LOW);
delayMicroseconds(2);

//sets the trig pin on high state for 10 microsecons 
  
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);

//reads the echo pin,returns the sound wave travel time

duration = pulseIn(echoPin,HIGH);

//calculating the distance 

distance = duration*0.034/2;
Indication = distance;
Serial.write(Indication);
if (Indication <= 5){
 digitalWrite(ledPin,HIGH); 
}
else{
 digitalWrite(ledPin,LOW);
  }
}




For any queries contact me on  -:tombriddle28@gmail.com

YouTube Channel-: Omnific{If this post helps you please do subscribe my               
            YouTube channel too ,It's only a click for you but it means a lot to me.}

Comments

Popular posts from this blog

Automatic Water Pumping System

Wireless Communication Between Two Arduino Board Using HC-05 Module

Interfacing "Bluetooth Module" with Arduino Uno