Parking Assist Sensor - Park Perfectly Everytime!

Introduction: Parking Assist Sensor - Park Perfectly Everytime!

This is a parking assist sensor that changes frequency and tone as you get closer to the desired target mark for parking. It uses an ultrasonic sensor to sense how far your car is from this safety distance.

Step 1: BoM

* Buzzer

* Arduino

* Ultrasonic Sensor

* Jumper Wires

* Breadboard

Step 2: Wiring

Follow the table below for the hardware connections:

I/O I/O PinArduino Pin
Ultrasonic Trig 10
Echo9
VCC3.3V
GNDGND
Buzzer16
2GND

Step 3: Code

// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
const int buzzer = 6;
// defines variables
long duration;
int distance;
int safetyDistance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(buzzer, OUTPUT);
  safetyDistance = 150;
 tone(buzzer, 2500);
  delay(500);
  tone (buzzer, 2500);  
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
int beep = map (distance, 0, 3000, 0, 10000);
int time1 = map (distance, 0, 3000, 0, 300);
tone(buzzer, beep, time1);
delay(time1);
noTone (buzzer);  
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(dist);
}
Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

Be the First to Share

    Recommendations

    • Fruit and Veggies Speed Challenge

      Fruit and Veggies Speed Challenge
    • Fandom Contest

      Fandom Contest
    • Backyard Contest

      Backyard Contest

    Comments