OBJECTIVE
The aim of this project prototype is it to design an reverse parking system which will assist the driver to make parking easily
MODULES REQUIRED
- Arduino Nano
- Ultrasonic Sensor
- Buzzer
- Jumper wire
SCHEMATIC DIAGRAM
Connect Ultrasonic sensor:
- Trig pin to Arduino Nano pin D12
- Echo pin to Arduino Nano Pin D11
Connect Buzzer:
- Connect the first pin(positive) on the buzzer to Arduino Nano pin D5
ARDUINO CODE
ARDUINO CODE
JavaScript
#define trigPin 12
#define echoPin 11
int Buzzer= 5;
int duration, distance;
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(Buzzer, OUTPUT);
}
void loop() {
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) / 29.1;
if (distance <= 60 && distance >= 50)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (500) ;
analogWrite(Buzzer, 255);
//tone(5,440,1000);
delay (500) ;
}
else if (distance <= 50 && distance >= 40)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (450) ;
analogWrite(Buzzer, 255);
//tone(5,440,1000);
delay (450) ;
}
else if (distance <= 40 && distance >= 30)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (250) ;
analogWrite(Buzzer, 255);
// tone(5,440,1000);
delay (250) ;
}
else if (distance <= 30 && distance >= 20)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (150) ;
analogWrite(Buzzer, 255);
//tone(5,440,1000);
delay (150) ;
}
else if (distance <= 20 && distance >= 10)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (100) ;
analogWrite(Buzzer, 255);
//tone(5,440,1000);
delay (100) ;
}
else if (distance <= 10 && distance > 5)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (50) ;
analogWrite(Buzzer, 255);
//tone(5,440,1000);
delay (50) ;
}
else if (distance <= 5 && distance >= 1)
{
Serial.println("object detected \n");
Serial.print("distance= ");
analogWrite(Buzzer, 0);
delay (10) ;
analogWrite(Buzzer, 255);
//tone(5,440,1000);
delay (10) ;
}
else
Serial.println("object detected \n");
Serial.print("distance= ");
Serial.print(distance);
analogWrite(Buzzer, 255);
//tone(5,440,1000);
{
}
}
INSTRUCTIONS
- Connect the modules and components as per the schematic diagram.
- Upload the Arduino code into the Arduino board.
- Check the reverse car parking safety mechanism, noting that the buzzer tone changes with the obstacle distance.
WORKING
- The Arduino Nano reads distance data from the ultrasonic sensor and activates the buzzer with increasing frequency as the car gets closer to an obstacle.