Parking Assist Sensor - Park Perfectly Everytime!
by TechMartian in Circuits > Sensors
996 Views, 7 Favorites, 0 Comments
Parking Assist Sensor - Park Perfectly Everytime!
![Screen Shot 2017-08-30 at 7.29.22 AM.png](/proxy/?url=https://content.instructables.com/FVE/FGM1/J6WGO9CS/FVEFGM1J6WGO9CS.png&filename=Screen Shot 2017-08-30 at 7.29.22 AM.png)
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.
BoM
![Screen Shot 2017-08-30 at 7.29.02 AM.png](/proxy/?url=https://content.instructables.com/FHR/MH49/J6WGO9C4/FHRMH49J6WGO9C4.png&filename=Screen Shot 2017-08-30 at 7.29.02 AM.png)
* Buzzer
* Arduino
* Ultrasonic Sensor
* Jumper Wires
* Breadboard
Wiring
![Screen Shot 2017-08-30 at 7.29.22 AM.png](/proxy/?url=https://content.instructables.com/FVE/FGM1/J6WGO9CS/FVEFGM1J6WGO9CS.png&filename=Screen Shot 2017-08-30 at 7.29.22 AM.png)
![Screen Shot 2017-08-30 at 7.29.17 AM.png](/proxy/?url=https://content.instructables.com/FNU/9NG8/J6WGO9CR/FNU9NG8J6WGO9CR.png&filename=Screen Shot 2017-08-30 at 7.29.17 AM.png)
![Screen Shot 2017-08-30 at 7.30.09 AM.png](/proxy/?url=https://content.instructables.com/FHJ/DGYF/J6WGO9CZ/FHJDGYFJ6WGO9CZ.png&filename=Screen Shot 2017-08-30 at 7.30.09 AM.png)
Follow the table below for the hardware connections:
I/O | I/O Pin | Arduino Pin |
---|---|---|
Ultrasonic | Trig | 10 |
Echo | 9 | |
VCC | 3.3V | |
GND | GND | |
Buzzer | 1 | 6 |
2 | GND |
Code
![Screen Shot 2017-08-30 at 7.32.43 AM.png](/proxy/?url=https://content.instructables.com/FFW/F0B1/J6WGO9EN/FFWF0B1J6WGO9EN.png&filename=Screen Shot 2017-08-30 at 7.32.43 AM.png)
![Screen Shot 2017-08-30 at 7.32.44 AM.png](/proxy/?url=https://content.instructables.com/FES/05VN/J6WGO9EW/FES05VNJ6WGO9EW.png&filename=Screen Shot 2017-08-30 at 7.32.44 AM.png)
// 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); }