Project tutorial
Parking Sensor Assistant

Parking Sensor Assistant © GPL3+

Can be used to determine how far away from say, a garage wall, the user is by warning them with use of a buzzer and various LEDs.

  • 609 views
  • 2 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

Application

The project makes use of an ultrasonic sensor, LEDs (visual aid) and a piezo buzzer (audio aid) to help assist in determining how far away from a wall a driver might be.

The closer to the wall the driver gets, the louder the buzzer gets and the greater number of various colored LEDs light up.

Connections

HC-SR04 ultrasonic sensor:

*Trigger pin to digital pin 7

*Echo pin to digital pin 6

*VCC to 5v

*GND to 0v(ground)

LEDS: (+ve legs to digital pins & -ve legs to GND)

*green led1 to digital pin 4

*green led2 to digital pin 5

*yellow led1 to digital pin 13

*yellow led2 to digital pin 12

*red led1 to digital pin 11

*red led2 to digital pin 10

*white led1 to digital pin 9

*white led2 to digital pin 8

Piezo Buzzer:

+ve leg to digital pin 3

-ve leg to GND

Layout & Operation

*nb. the transistor is not required for an ordinary piezo buzzer but it is recommended that you use a resistor with the buzzer, if the buzzer volume is too low, you can lower the value of the resistor. (so maybe replace the 1k Ohm with a 220 Ohm resistor). Or you could just change the values of the variable "sound" in the code to suit your project.

I hope I didn't forget to cite additional sources of inspiration. If I clearly used some verbatim pieces of your code to build the functions on this page and forgot to cite you, contact me and I may add a link to your work.

Code

Parking Sensor Assistant CodeArduino
/*Parking Sensor Assistant*/
#define ledGreen1 4
#define ledGreen2 5
#define trigPin 7
#define echoPin 6
#define ledYellow1 13
#define ledYellow2 12
#define ledRed1 11
#define ledRed2 10
#define ledWhite1 9
#define ledWhite2 8
#define buzzer 3

int sound = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(ledWhite1, OUTPUT);
  pinMode(ledWhite2, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(ledGreen1, OUTPUT);
  pinMode(ledGreen2, OUTPUT);
  pinMode(ledYellow1, OUTPUT);
  pinMode(ledYellow2, OUTPUT);
  pinMode(ledRed1, OUTPUT);
  pinMode(ledRed2, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  long timeTaken, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  timeTaken = pulseIn(echoPin, HIGH);//determine distance of wave
  distance = (timeTaken/2)/29.1;//using timeTaken calc distance of object

  /*determine corressponding leds to light up with respect to the distance
  of object*/

  if(distance<81){
      digitalWrite(ledGreen1, HIGH); sound = 600;
    }else{
      digitalWrite(ledGreen1, LOW);
      }

   if(distance<71){
      digitalWrite(ledGreen2, HIGH); sound = 800;
    }else{
      digitalWrite(ledGreen2, LOW);
      }
  
  if(distance<61){
      digitalWrite(ledYellow1, HIGH); sound = 1000;
    }else{
      digitalWrite(ledYellow1, LOW);
      }
      
   if(distance<51){
      digitalWrite(ledYellow2, HIGH); sound = 1200;
    }else{
      digitalWrite(ledYellow2, LOW);
      }

    if(distance<41){
      digitalWrite(ledRed1, HIGH); sound = 1400;
    }else{
      digitalWrite(ledRed1, LOW);
      }

    if(distance<31){
      digitalWrite(ledRed2, HIGH); sound = 1600;
    }else{
      digitalWrite(ledRed2, LOW);
      }

    if(distance<21){
      digitalWrite(ledWhite1, HIGH); sound = 1800;
    }else{
      digitalWrite(ledWhite1, LOW);
      }

    if(distance<11){
      digitalWrite(ledWhite2, HIGH); sound = 2000;
    }else{
      digitalWrite(ledWhite2, LOW);
      }

      /*buzzer tone*/
      if(distance>80||distance<=0){
          noTone(buzzer);
         
        }else{
          tone(buzzer, sound);
         
        }
        
      
      delay(500);
}

Schematics

arduinomega2560r3_xpytisesvo.PNG
Arduinomega2560r3 xpytisesvo
Schematics for parking sensor assistant
Parkingsensorassistantschematic dbzmuygwfk
basicled_kD6OCv5ENF.PNG
Basicled kd6ocv5enf
ultrasonicsensor_NHYSddtX5Y.PNG
Ultrasonicsensor nhysddtx5y
piezo_PpgZ4YiAKL.PNG
Piezo ppgz4yiakl
transistor_6mb8TCutSR.PNG
Transistor 6mb8tcutsr
breadboard_uz8ags4RS2.PNG
Breadboard uz8ags4rs2
1kresistor_aM4SZ1dsM9.PNG
1kresistor am4sz1dsm9
330ohmresistors_INQymXmOrP.PNG
330ohmresistors inqymxmorp

Comments

Author

Tr3v3n jaganath
Tr3v3n_Jaganath
  • 0 projects
  • 1 follower

Additional contributors

Published on

January 16, 2019

Members who respect this project

Photo12106925 10207887238402582 2031126001774239206 nGoldrake 5zbyrwz02tPhotoDefaultPhoto18519821 10210612391839040 7063500931368551327 nProfilepic

and 1 other

See similar projects
you might like

Similar projects you might like

Parking Sensor with Arduino

Project showcase by Team VINICIUS LOPES

  • 9,934 views
  • 4 comments
  • 17 respects

DIY - ARDUINO BASED CAR PARKING ASSISTANT

Project tutorial by Tarantula3

  • 2,856 views
  • 2 comments
  • 17 respects

Hall effect sensor with Arduino

Project tutorial by AMAL NS

  • 9,611 views
  • 1 comment
  • 23 respects

IOT - Smart Jar Using ESP8266, Arduino and Ultrasonic Sensor

Project tutorial by Team Smazee

  • 6,449 views
  • 4 comments
  • 13 respects

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 5,727 views
  • 7 comments
  • 20 respects

Ambient Light Sensor Using Photo Resistor and LED Lights!

Project tutorial by DCamino

  • 3,512 views
  • 4 comments
  • 17 respects
Add projectSign up / Login