Automatic Obstacle Dictector
This is to present you a simple and cost-efficient obstacle detecting Circuit. The system was implemented in C++ type Arduino coding Software. Inputting the data and processing it in Arduino; all were digitally maintained; the digital pins of Arduino were used. And the outputs were controlled by the Arduino which were pre-given. This simple, cost efficient and mostly accurate project can be used in farming as well as defense and security sector of any country.
Components Required
Arduino NANO or Uno (any version)
HC-SR04 Ultrasonic Sensor
Battery
LED
Chassis
Jumper Wires
Circuit Diagram
Ultrasonic sensors also known as Sonar sensors have been in use for decades. They were once used for mapping of ships in sea and detection of broken/faulty parts in mechanical systems. The ultrasonic sensor works by transmitting ultrasonic waves and these waves strike with obstacles placed in front of the transmitter. The waves are reflected and hit on the receiver. The time taken by the waves from transmission to receiving with respect to the velocity of ultrasonic waves is used to measure the distance of obstacle present ahead.
The speed of sound is approximately 341 meters (1100 feet) per second in air. The ultrasonic distance sensor uses this information along with the time difference between sending and receiving the sound signal to determine the distance between object. It uses the following mathematical formula.
Distance = Time x Speed of Sound divided by 2
Time = the time between when an ultrasonic wave is transmitted and when it is received
this number is divided by 2 because the sound wave has to travel to the object and back.
Since the distance can’t be changed in physically in simulation, the simulation model of SR04 is connected with a potentiometer, and the distance for the sensor is varied using this potentiometer.
Simulation
Proteus 8 based simulation model has been demonstrated here.
The working mechanism of this project is simple and easy to understand. The ultrasonic sensor has 4 pins out of which 2 pins are for power, and the remaining 2 pins are for the trigger and echo. The MCU transmits ultrasonic waves through the trigger pin and then reads the receiving time of that ultrasonic wave on echo pin. The velocity of the ultrasonic wave traveling is defined and accordingly the distance is measured.
It is essential to add a hex file of Arduino code in its simulation model. The hex file is in the form of binary instructions given to the MCU for processing.
LCD serves as a graphical interface for displaying results. The display brightness can be adjusted by supplying 0-5v on pin 3 which is unnecessary in case of simulation but works well for hardware design. Make sure the pins are carefully connected with Arduino as mentioned in the circuit diagram.
The use of 10k Preset is only in simulation for making a Object between sensor . Here the preset is works as object.
The use of a potentiometer with the Ultrasonic sensor enables the user to control the input distance for sensor and observe changes in results accordingly. The value of this potentiometer must be above 1K ohm.
Since the simulation model ensures proper functioning of the design, if your simulation works correctly, you can proceed towards the development of hardware design. However in case if your simulation is not working correctly, you need to troubleshoot your error.
If your LCD is displaying distance and it varies but the distance is incorrect, you might be directing your Ultrasonic sensor in the wrong manner, make sure the path is clear between target obstacle and Ultrasonic sensor and the sensor is facing an obstacle. Alternatively, the connections of the ultrasonic sensor with Arduino might be wrong. If there is no display on the LCD, then you need to check code and connections of LCD with Arduino.
Failing to connect all components as instructed in the circuit diagram, the simulation might not work or show unexpected behavior.
Code
#include
#define Trig 8
#define Echo 9
#define led 10
#define buzzer 11
long duration;
float (distance);
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
void setup() {
pinMode(Trig,OUTPUT);
pinMode(Echo,INPUT);
pinMode(led,OUTPUT);
pinMode(buzzer,OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
}
void loop() {
// set the cursor to column 0, line 1
digitalWrite(Trig,LOW);
delayMicroseconds(2);
digitalWrite(Trig,HIGH);
delayMicroseconds(10);
digitalWrite(Trig,LOW);
duration=pulseIn(Echo,HIGH);
distance=duration/58.2;
if(distance<30){
digitalWrite(led,HIGH);
digitalWrite(buzzer,HIGH);
lcd.setCursor(1,0);
lcd.print("DANGER AHEAD!!!");
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print("Obstacle is");
lcd.setCursor(12, 1);
lcd.print(distance);
lcd.setCursor(14, 1);
lcd.print("cm");
}
else {
digitalWrite(led,LOW);
digitalWrite(buzzer,LOW);
lcd.clear();
lcd.setCursor(1,0);
lcd.print("No Obstacle");
lcd.setCursor(0,1);
lcd.print("Drive Safe");
}
}
APPLICATIONS
This can be used in Modern Car Automations.
Used in Robot Manufacturing etc
Comments