Step 1: Placing the Device
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
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
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
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
#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
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...!!!!!!!!!!!!!!!!!!!!