Parking Sensor

by sherbrookm in Circuits > Arduino

149 Views, 2 Favorites, 0 Comments

Parking Sensor

DISTANCE PROXIMITY ALERT.png

This Arduino is equipped with an ultrasonic distance sensor, capable of calculating distances up to 13 feet. It's purpose is to warn the driver how close their vehicle is to hitting the wall.

Supplies

1 Arduino

6 Wires

1 Ultrasonic Distance Sensor

1 Buzzer

Wire 1

STEP 1.png

Connect Wire 1 to the 5V of the Arduino board. Connect the other side to the 5V of the Ultrasonic Distance Sensor.

Wire 2

STEP 2.png

Connect Wire 2 to the GND of the Arduino. Connect the other side to the GND of the Ultrasonic Distance Sensor.

Wire 3

STEP 3.png

Connect Wire 3 to the GND of the Arduino. Connect the other side to the + side of the buzzer.

Wire 4

Screenshot 2023-05-29 181434.png

Connect Wire 4 to the -5 of the Arduino. Connect the other side to the - side of the buzzer.

Wire 5

Screenshot 2023-05-29 181623.png

Connect Wire 5 to the 8 of the Arduino. Connect the other side to TRIG of the Ultrasonic Distance Detector.

Wire 6

STEP 6.png

Connect Wire 6 to the 7 of the Arduino. Connect the other side to ECHO of the Ultrasonic Distance Detector.

Code

Paste The Following Code Into The Arduino Software:


int buz = 5;

int echoPIN = 7;

int trigPIN = 8;


boolean buttonOn = false;


void blinkSlow()

{

 tone(buz,500);

 delay(400);

 noTone(buz);

 delay(800);

}


void blinkMedium()

{

 tone(buz,700);

 delay(200);

 noTone(buz);

 delay(300);

}


void blinkFast()

{

 tone(buz,850);

 delay(200);

 noTone(buz);

 delay(200);

}


void setup() {

  pinMode(echoPIN, INPUT);

  pinMode(trigPIN, OUTPUT);

  Serial.begin(9600);

}


void loop() {

  long duration, distance;

  digitalWrite(trigPIN,HIGH);

  delayMicroseconds(1000);

  digitalWrite(trigPIN,LOW);

  duration = pulseIn(echoPIN,HIGH);

  distance = (duration/2)/29.1;

  Serial.print(distance);

  Serial.println("CM");

  delay(10);

 if (distance < 12) tone(buz,1000);

 else

    if (distance < 50) blinkFast();

  else 

  if (distance < 150) blinkMedium();

   else 

   if (distance < 300) blinkSlow();

   else

    noTone(buz);

  }

RUN

Connect the Arduino to a computer via USB.

Compile the code into the Arduino using Arduino IDE.

Turn on the Arduino and your done!