PARKING SENSOR

OVERVIEW

Today our project is a very interesting and engaging one. We would be making a parking Sensor. Most modern cars come with an inbuilt sensor for reverse parking to alert the driver when his/her bumper is too close to the wall of the garage or an object to prevent damage to the vehicle. This can also help in regulating the distance between cars in traffic. The best sensor to use for this project is an Ultrasonic sensor which can be used to determine the proximity of an object from another.

 

DETAILS 

In this project we set a maximum proximity for the buzzer to start beeping and the respective LEDs to start blinking, oh yes I used LEDs !!, 3 specifically with different colors and it made the project more interesting. I connected the Ultrasonic Sensor to the Arduino Uno by connecting its VCC to 5v, its Trig to digital pin 9, its Echo to digital pin 10 and its ground to ground of the Arduino Uno. For the buzzer, I used a passive buzzer here and I connected its shorter leg to ground and  its longer leg to a resistor and serially to digital pin 12. Finally, I connected each of the shorter pins of the Red, Yellow and Green LEDs to the ground of the Arduino Uno and each of their longer pins to a resistor each and serially to digital pins 5, 6, 3 respectively.

The materials needed for this project are as follows;

All these components are available in the Invent Arduino Starter Kit.

As mentioned earlier, the Ultrasonic Sensor is the main unit (component) that is responsible for measuring the distance. Arduino UNO acts as the main controlling unit that will control the Ultrasonic Sensor, calculate the distance and activate the buzzer.The principle of the circuit is as follows: The Ultrasonic Sensor sends acoustic pulses and the Arduino measures the interval of each reflected signal. Based on this time interval, Arduino then calculates the distance of the object. Arduino then activates the Buzzer if the distance between the sensor and object is less that a certain range.
When the circuit is completed and the code is uploaded, the green Led should be on and the buzzer should be off so far as there’s no object within any of the set proximity. Once any object comes in any of the set proximity depending on the range, the specified Led should begin blinking and the buzzer would also start beeping.

 

SCHEMATIC

CODE

const int trigPin = 9;
const int echoPin = 10;
long duration;
int distance;
const int buzzer = 12; //buzzer pin 12 
const int redled = 5;
const int yellowled = 6;
const int greenled = 3;

void setup() {
  // put your setup code here, to run once:
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(redled, OUTPUT);
  pinMode(yellowled, OUTPUT);
  pinMode(greenled, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly: 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = 0.034*(duration/2);
  Serial.println(distance);
  Serial.println(duration);
 
 if (distance <= 50 && distance >=30){
  digitalWrite(greenled, LOW);
  digitalWrite(redled, LOW);
  for (int a=1; a<=5; a++ ){
  digitalWrite(buzzer, HIGH);
  delay(100);
  digitalWrite(buzzer, LOW);
 
 digitalWrite(yellowled, HIGH);
 delay(100);
 digitalWrite(yellowled, LOW);
  }
 
 }

 else if (distance < 30){
  digitalWrite(yellowled, LOW);
  digitalWrite(greenled, LOW);
  for (int a=1; a<=5; a++ ){
  digitalWrite(buzzer, HIGH);
  delay(50);
  digitalWrite(buzzer, LOW);
  
  digitalWrite(redled, HIGH);
  delay(50);
 digitalWrite(redled, LOW);
  
  }
  }
 else{
digitalWrite(buzzer, LOW);
digitalWrite(yellowled, LOW);
digitalWrite(redled, LOW);
digitalWrite(greenled, HIGH);

}
 
}

 

FINAL SETUP

 

0 0 vote
Article Rating
0
Would love your thoughts, please comment.x
()
x