Introduction: Awesome Arduino Adventure
Are you excited about Arduino!!! Well you have come to the right place!!!! My sister and I have made a distance sensor parking garage meter! The purpose for this device is to help you try to park your car in the garage, safely. As a driver you have no idea if the car is too close to the wall or too far from the wall that prevents the garage door from closing. It might close and hurt your car in the process!!! That’s not good. This device prevents you from all that trouble. To get an idea of about what I am talking about look at the picture above……
Step 1: Placing the Device
As you can see in this picture, the car has to be within the right distance from the wall to be parked safely.
So, we have built a parking garage meter to help the driver by making different color LEDs (light emitting diodes) light up.
For example, if the car is close enough to the wall that the car is about to bump into objects in the front, the blue led will glow. If the car is parked too far from the wall and the garage door can’t close, the red led will glow. Any distance between these 2 places is the safe zone and the green led will glow. So now you see why this device is very useful for drivers who park their cars in garages. The finished device looks a little like this picture above.
Step 2: Items Needed for This Project
All these items are available at any electronic store
For this project we are using:
3 LEDs( green, blue, red)
Pack of wires
USB cable to connect computer to Arduino
Ping Sensor HC-SR04
All of these items except for the ping sensor come in the Arduino Uno starter’s kit available in Radio Shack. You can also buy these items individually if you want. You can find this model of the ping sensor at Vetco Electronics.
Step 3: Connecting the Ping Sensor
1. Connect the 5V of the Arduino to the outside +ive rail of the bread board.
2. Connect the GND to the –ive rail of the bread board.
3. Wire the Ping sensor (pins VCC and GND) to the correct locations in the bread board. (Now the Ping sensor is powered)
4. Connect Trig pin of the sensor to the Pin 12 of the Arduino board.
5. Connect the Echo pin of the sensor to the Pin 11 of the Arduino board.
Now the ping sensor is wired completely.
Step 4: Connecting the LEDs
Connect the LEDs as described below
Blue LED +ive to Arduino pin 8
Red LED +ive to Arduino pin 9
Green LED +ive to Arduino pin 11
Remember to connect the –ive pin to GND.
Step 5: Time for Some Code
Here are some important pieces of the software that we used to program his device.
#define justRightLed 11 // green
#define faulty 10 // do not use
#define tooFarLed 9 // red
#define tooCloseLed 8 // blue
#define ECHO_PIN 12
#define TRIGGER_PIN 13
Change these values for your garage
double tooCloseInches = 5;
double tooFarInches = 20;
In setup function, make sure you set the pins to the correct mode
This code Lights up or shuts off all the LEDs …. Use when testing..
The main loop
unsigned int uS = sonar.ping();
double distanceCM = uS / US_ROUNDTRIP_CM;
double distanceIn = uS / US_ROUNDTRIP_IN;
if (distanceIn > 0.1) displayCorrectStatus(distanceIn);
First check if the distance measured is greater that the too close line AND if the distanced is less than the 2 far line, - at this time we know it is in the safe zone
Next, check if the distance is too close, then the blue LED lights up.
Lastly, the Red LED lights, if the distance is too far.
void displayCorrectStatus(int distanceIn)
if ( (distanceIn >=tooCloseInches) && (distanceIn <= tooFarInches ))
else if ( distanceIn < tooCloseInches)
Step 6: All Done
Now after all this is finished we now have a complete product which will look like this.
HAVE FUN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! My sister and I are 11 years old and have been working on this project for the last 2 months. If you have feedback we will be glad to hear them.. The most exciting part of this project was when it all came together and we saw it work . Try it yourself ... Now we don't have a problem with parking the car...!!!!!!!!!!!!!!!!!!!!