0% found this document useful (0 votes)
3 views

Obstacle Detection

The document provides an overview of obstacle detection systems, detailing their applications, components, and various types such as radar and ultrasonic sensors. It includes specific projects using Arduino Nano, ultrasonic sensors, LEDs, buzzers, and servo motors to create obstacle detection systems with corresponding circuit diagrams and code examples. The projects demonstrate how to use these components to measure distances and provide visual or audible alerts based on obstacle proximity.

Uploaded by

killer38clown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Obstacle Detection

The document provides an overview of obstacle detection systems, detailing their applications, components, and various types such as radar and ultrasonic sensors. It includes specific projects using Arduino Nano, ultrasonic sensors, LEDs, buzzers, and servo motors to create obstacle detection systems with corresponding circuit diagrams and code examples. The projects demonstrate how to use these components to measure distances and provide visual or audible alerts based on obstacle proximity.

Uploaded by

killer38clown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

OBSTACLE

DETECTION
Introduction
• An obstacle detection system is a device or system that is designed to detect the presence of
obstacles in a specific area.

• These systems can be used in a variety of applications, such as in vehicles to assist with driving, in
robotics to help with navigation, and in industrial settings to protect workers and equipment.

• Common types of obstacle detection systems include radar, lidar, ultrasonic sensors, and
cameras.

• These systems use different techniques to detect obstacles, such as measuring distance, using
infrared radiation, or analyzing images.
Components Required
• Arduino Nano

• Ultrasonic Sensor - HCSR04

• Bread Board

• Jumper Wires

• LED

• Resistor

• Buzzer

• Micro servo motor


Arduino Nano

• The Arduino Nano is an open-source breadboard -friendly


microcontroller board based on the Microchip ATmega328P
microcontroller (MCU) and developed by Arduino.cc and
initially released in 2008. It offers the same connectivity and
specs of the Arduino Uno board in a smaller form factor.

• The Nano has 14 digital pins, 8 analog pins, 2 reset pins,


and 6 power pins.

• It operates at 5V, but the input voltage can vary from 7V to


12V.
Pin Diagram
Buzzer

• A buzzer is an electronic device that


produces a sound when an alternating
current is applied to it.

• It is used for a variety of purposes, such as


in alarms, timers, and other devices that
need to produce an audible signal.
Ultrasonic Sensor
(HC-SR04)

• The sensor sends out a 40kHz sound wave, and then


measures the time it takes for the sound wave to bounce
back to the sensor.

• By measuring the time it takes for the sound wave to travel


to an object and back, the HC-SR04 can calculate the
distance to that object

• It is commonly used in robotics, automation and other


projects where distance measurement is required.
Resistor

• Resistance is the measure of a material’s ability to


oppose the flow of electric current.

• It is measured in units of ohms (Ω).

• The resistance of a material is determined by its


composition and temperature, and can be affected by
changes in temperature and the presence of
impurities.
Bread Board

• A test plate, also known as a test jig, is a device used to


test electronic circuits and components.

• It is a board or plate that has been designed to hold and


connect various components and devices in a specific
configuration, allowing for the easy testing and
measurement of their performance.
Connecting wires
(Jumper wires)

• Connecting wires are used to connect various


components in an electronic circuit.

• They allow for the transfer of electricity, data, or


signals between different devices and components.
LED

• A LED (Light Emitting Diode) is a type of


semiconductor device that emits light when a current is
passed through it.

• LEDs are made of a material called a semiconductor,


which is a type of material that has electrical properties
that fall between those of a conductor and an insulator.

• When a current is passed through an LED, it causes the


electrons in the semiconductor to become excited and
release energy in the form of light.
Micro Servo Motor

• A servo motor is a type of electric motor that can rotate or


move to a specific position, speed, or torque based on an input
signal from a controller.

• The term servo comes from the Latin word servus, meaning
servant or slave. This reflects the historical use of servo
motors as auxiliary drives that assist the main drive system.
Project- 1
Obstacle detection using LED
Circuit Diagram
CODE
#define pingPin 2 //trig pin of sr04
#define echoPin 3
void setup() {
Serial.begin(9600); // Starting Serial Terminal
pinMode(pingPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(12,OUTPUT); //pin12 is used as GND pin for LED since arduino nano has only two GND pins
pinMode(A3,OUTPUT); //pin A3 provides the output on LED
}
void loop() {
long duration, cm;
digitalWrite(12, LOW); //LED GND is always low
CODE
//send a signal at ping pin at an interval of 0.002 seconds to check for an object
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);

duration = pulseIn(echoPin, HIGH); //check time using pulseIn function


cm = microsecondsToCentimeters(duration); //functin call to find distance
if (cm<30&&cm>0)
{analogWrite(A3,255);
delay(100);
analogWrite(A3,0);
delay(100); } //Light LED every second if obstacle distance is between 20-30cm.
CODE
else
analogWrite(A3,0); //do not light
}

//function to return distance in cm from microseconds


long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
Project- 2
Obstacle detection using Buzzer
Circuit Diagram
CODE
#define pingPin 2 //trig pin of sr04
#define echoPin 3
void setup() {
Serial.begin(9600); // Starting Serial Terminal
pinMode(pingPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(12,OUTPUT); //pin12 is used as GND pin for buzzer since arduino nano has only two GND
pins
pinMode(A3,OUTPUT); //pin A3 provides the output on buzzer
}
void loop() {
long duration,
cm;
digitalWrite(12, LOW); //Buzzer GND is always low
//send a signal at ping pin at an interval of 0.002 seconds to check for an object
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);

duration = pulseIn(echoPin, HIGH); //check time using pulseIn function


cm = microsecondsToCentimeters(duration); //function call to find distance.
if (cm<30&&cm>20) {
analogWrite(A3,255);
delay(1000);
analogWrite(A3,0);
delay(1000);
}
//sound buzzer every second if obstacle distance is between 20-30cm.
else if (cm<20&&cm>10) {
analogWrite(A3,255);
delay(500);
analogWrite(A3,0);
delay(500);
}
//sound buzzer every 0.5 seconds if obstacle distance is between 10-20cm.

else if (cm<10&&cm>0) {
analogWrite(A3,255);
delay(100);
analogWrite(A3,0);
delay(100);
}
//sound buzzer every 0.1 seconds if obstacle distance is between 0-10cm
else
analogWrite(A3,0); //do not sound the buzzer
}
//function to return distance in cm from microseconds
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
Project - 3
Servo Distance Indicator
Circuit Diagram
CODE
#include <Servo.h>
#include <NewPing.h>

const int trigPin = 2;


const int echoPin = 3;
const int ServoPin = 12;

long duration;
int distance;
Servo servo;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
servo.attach(ServoPin);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);


distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.println(distance);

int angle = map(distance, 2, 15, 15, 100);


angle = constrain(angle, 15, 100); // Ensure angle is within servo limits
servo.write(angle);

delay(50);
}
TASK
LED Distance Indicator
Circuit Diagram
CODE
#define pingPin 2 //trig pin of sr04
#define echoPin 3

void setup() {
Serial.begin(9600); // Starting Serial Terminal
pinMode(pingPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(12,OUTPUT);
pinMode(A3,OUTPUT); //pin A3 provides the output on led
pinMode(11,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(10,OUTPUT);
pinMode(A1,OUTPUT);
}
void loop() {
long duration, cm;
digitalWrite(12, LOW); //led GND is always low
digitalWrite(11, LOW);
digitalWrite(10, LOW);

//send a signal at ping pin at an interval of 0.002 seconds to check for an object
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
duration = pulseIn(echoPin, HIGH); //check time using pulseIn function
cm = microsecondsToCentimeters(duration); //functin call to find distance

if (cm<30&&cm>20){
analogWrite(A1,255);
delay(1000);
analogWrite(A1,0);
delay(1000);
} //light green led if obstacle distance is between 20-30cm.
else if (cm<20&&cm>10) {
analogWrite(A2,255);
delay(500);
analogWrite(A2,0);
delay(500);
} //light blue led if obstacle distance is between 10-20cm.

else if (cm<10&&cm>0) {
analogWrite(A3,255);
delay(100);
analogWrite(A3,0);
delay(100);
} //light red led if obstacle distance is between 0-10cm.

else
analogWrite(A3,0); //do not light
}
//function to return distance in cm from microseconds
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
Thank You

You might also like