Introduction: Arduino Ultrasonic "Parking Spotter"

Picture of Arduino Ultrasonic "Parking Spotter"

     For my first instructable, I'd like to present The Parking Spotter. This is not a new concept, I know. However, this build was done specifically to suit my needs/wants/materials already in my possession. Typically, a project begins with an idea, parts are then gathered, and the building commences. In my case I looked around at the parts and material that I had on-hand, browsed Instructables (a daily occurrence), and found inspiration from others. I shouldn't fail to mention the site of wooden saw horses in front of my sister-in-laws $30k car to protect the $200 bicycle!! So, let's dive in!

BOM (bill of materials):

* Arduino Uno, clone (Freeduino, etc.), compatible (Perfboard Arduino, etc.)
* SRF04 Ultrasonic Ranging Sensor
* (8) 5mm LED's for indicator lights (I used red, yellow, and green for this project; but you can use whatever colors you would like)
* (4) Appropriate resistors for your LED's (I used 100 Ohm for red & yellow, and 82 Ohm for green)
* (9) LED holders of your choosing (I used LED Holder Model:276-079 for the indicator lights, and LED Holder Model:276-080 for the power indicator/pathway light)
* (1)Power-On/Walkway 5mm LED & resistor(for pathway illumination in front of your car)
* SPST switch (power)
* Power source - I used a wall wart with 7.4v DC output because, well, I had one on my bench. You can use a 9v battery & battery clip. I just don't want to mess with batteries.
* Wire
* Heat-shrink tubing and/or electrical tape
* An enclosure (I used the plastic 4" x 6" enclosure from Radio Shack)
**     Optional:
     * One row of (5) male header pins
      *Hook-up wire with female connectors: (5) for the LED's & (4) for the sensor
* PCB standoffs
* cyanoacrylate (super glue, finger nail glue)


Soldering iron, solder & fume extractor
Drill or drill-press
Appropriate drill bit for your LED holders
5/8" drill bit for the sensor holes
Screwdriver for the enclosure
And, anything that you feel you need to make your task easier.

I am going to assume that you are, at least, familiar with the Arduino development platform. If you are not, I suggest visiting the Arduino homepage. Study the hardware and software. Learn the basics. Build some circuits (actually, this could be your first! It's not that hard!) When you have reached that point, learn more! I've been learning this stuff on my own with TONS of help from the wealth of information on the Arduino site, great Instructables members and the web in general.

Step 1: Layout Design

Picture of Layout Design

As I said, the choice is up to you as to what Arduino or Arduino-compatible board you use. As for me? Well, I built my own board based on this Instructable - Perfboard Hackduino (Arduino-compatible circuit) by jmsaavedra and the paper breadboard overlay from Sparkfun. Pay close attention to the 5v regulator part of the circuit in the Perfboard Hackduino 'able, though. Read the entire 'able & comments before you start. It's good, but can be confusing if you don't pay attention.
Referring to the photo 1 notes, there are two sets of red/black wires. The set toward the top of the picture is for a power indicator LED & the other is for power. I used a wall wart with an output of 7.4v DC. You can use a 9v DC battery, if you prefer, but I didn't want to have to mess with changing batteries.

Once my perfboard had the ATMega circuit on it, I prepared my enclosure. I laid out the parts (8 LED's with resistors & ultrasonic sensor) on the lid of the enclosure to determine two things: aesthetics & roughly how much wire I would need (Sorry, no pics of this step). The placement can be of your own liking. I got my inspiration from yet another Instructable, Ultrasonic Parking Sensor by atatistcheff. I like a lot of LED's. :)

Step 2: Construction Begins

Picture of Construction Begins

Once the locations were determined, I marked & drilled the holes for the (8) LED's & the sensor.
As you can see in the first photo, I was going to use the metal cover that came with the enclosure, but later scrapped it.

In the second photo, you can see that my 5/8" holes may have been a "bit" big. But, I discovered that a standard garden-hose rubber washer fits over the sensor "barrels" perfectly. So, I glued them on with cyanoacrylate (super glue, finger nail glue) and then colored them with a black permanent marker. Problem solved! :) This also holds the sensor nearly flush with the enclosure.

You also need to prepare the enclosure for mounting your circuit board, switch, power indicator LED &, if using a wall wart, a place for the power to enter. If you're using the same enclosure as me, it is deep enough that you can mount the board anywhere on the bottom and have plenty of clearance. Mark the holes and drill them. You can test fit the board but, if you're using a board without female headers, you will need to take it back out for soldering.
The power/illumination LED gets mounted so that it will be shining on the ground, & the switch can be wherever you would like it. Drill the appropriate size holes for your components.
One last hole. It's for the wall wart wire. I placed mine at the back of the bottom of the enclosure.

Clean all holes of any burs left from drilling.

Now is the time to make sure you know which pins are what on the SR04 ultrasonic sensor. I have marked the voltage pin red & the ground pin black with permanent marker & wrote the pin description on the back of my overlay paper. See photo 4.

Next, mount the LED's using the LED holders or glue, and the ultrasonic sensor with glue.

Step 3: Let the Soldering Begin!

Picture of Let the Soldering Begin!

Time to start soldering.
Working on the inside of the lid: The LEDs are soldered: red-red in series; yellow-yellow in series; yellow-yellow in series; green-green in series, along with the (4) resistors as mentioned in the BOM: (100 Ohm for red & yellow, and 82 Ohm for green). I forgot about the heat shrink until I had the LEDs connected so, I wrapped a piece of electrical tape around them & placed heat shrink on the common cathode. I then soldered all of these leads to the 5-pin-row male header. NOTE: By using the center pin for ground (-), if you plug it in backwards, it will still work. A good bead of hot glue was then applied to secure the header to the lid. (Photo 1)

For the connection wires, I used female jumper wires with one end cut & stripped. Make things easy on yourself -
LED distance indicators wires: red wire for red LEDs, yellow wire for yellow LEDs, green wire for green LEDs.

Red wire to Digital Pin 5 (chip pin 11)
Yellow wire to Digital Pin 4 (chip pin 6)
Yellow wire to Digital Pin 3 (chip pin 5)
Green wire to digital pin 2 (chip pin 4)
Another dab of hot glue to help secure the wires onto the board.

Ultrasonic sensor wires: red wire for VCC (+), green wire for trigger, orange wire for echo, black wire for gnd (-)

Red wire to +5v on board
Green wire to Digital Pin 8 (chip pin 14)
Orange wire to Digital Pin 7 (chip pin 13)
Black wire to ground (-) on board

Now take your female wire ends and super glue them together in their respective groups to form plugs; LED wires in one plug & sensors wires in the other. You could omit the two plugs and just solder the wires directly to your components, but it's nice to be able to completely separate the lid from the base when working on things.

Step 4: No Need to Feel Powerless!!!

Picture of No Need to Feel Powerless!!!

I cut the the plug off the wall wart, leaving it as long as possible, and stripped the ends of the wire, ran it through the hole drilled for it and soldered it according to the picture-notes in photo one:
#1: (+) from power supply (wall wart) to switch.
#2: (+) from switch to regulator circuit on board.
#3: (-) from wall wart to (-) of regulator circuit on board.

Next is the Power indicator LED:
#A: Knot tied in wire from wall wart AFTER feeding it through the hole, BEFORE soldering them!
#4: (+) & (-) from voltage regulator circuit to power indicator LED.
#4a: (-) for LED.
#4b: (+) for power indicator to 100 Ohm resistor to LED anode.
#5: Pathway Illumination LED mounted to bottom (when mounted on wall) of enclosure.

I love hot glue! It helps hold wires in place nicely!! :)

Step 5: And One Sketch to Rule Them All

Picture of And One Sketch to Rule Them All
The sketch that I used was first modified by Michael LeBlanc here, which is adapted from the David Mellis/Tom Igoe “Ping Sensor” example that comes with the current Arduino IDE, as well as, the Ping Tutorial on the Arduino website. I further modified it to fit my needs. To be honest, it took me a day to figure out what I needed to do to modify it. You see, I've only been into electronics for a few months, and it didn't start with Arduino. But, I'll not get sidetracked with that.
I included the MsTimer2.h  & NewPing.h files for better accuracy.
For the other changes, you can compare the three sketches. I'll not try explain them, because I'm not a programmer. Besides, figuring out some of this stuff on your own is part of the fun. Not to mention the fact that Michael LeBlanc did most of the changes, and did them well. Thank you, Michael!
The biggest change I made was:

From this:

The circuit:
    * +V connection of the PING))) attached to +5V
    * GND connection of the PING))) attached to ground
    * SIG connection of the PING))) attached to digital pin 7

The PING))) is a three-pin sensor: the trigger & echo are on the same pin.

To this:

The circuit:
    * +V connection of the SRF04 attached to +5V
    * GND connection of the SRF04 attached to ground
    * Trig "Trigger" connection of the SRF04 attached to Digital pin 8
    * Echo connection of the SRF04 attached to Digital pin 7

The SRF04 has separate pins for trigger & echo.

So, this:
const int pingPin = 7;

#define TRIGGER_PIN  8  // Arduino pin tied to Trig pin on ultrasonic sensor.
#define ECHO_PIN     7  // Arduino pin tied to Echo pin on ultrasonic sensor.

I don't remember why I changed const to #define, but it works. :)

Now, before you install it (hang it on the garage wall),  find someone to help you calibrate it. To do this, I held the device against the wall & my brother drove the car, stopping at each stage of lighting. Measurements were taken, & it was agreed that I nailed it the first time. No need for adjustments! This is because I had measured before I uploaded the final sketch, and input my numbers into the code. Something I could have mentioned sooner.

Distances can be changed to suit your needs. Look over the sketch and see what you've learned or can learn. If you have specific questions, ask. If I can't answer them, maybe someone else can.

Thanks for checking out my first Instructable! I hope it was interesting enough for you to be reading this sentence!! :)

P.S. - Check out The Parking Spotter on Adafruit's Show & Tell from 1-5-2013 (my segment starts at 17:40) & on the Adafruit Blog


Chinasaur (author)2013-01-17

I remember someone posting something like this; he pointed out that you can get salvage ultrasonic rangers from auto scrapyards for very cheap. Obviously more involved to get it wired up, but if you want to cut BoM costs maybe look into it.

AptPupil (author)Chinasaur2013-01-17

Chinasaur, I actually got mine on Ebay for about $2US. I just won another bid - (2) for $4.35US with free shipping. I've read that there are more accurate ultrasonic sensors available, and maybe you can find one of those. That is a very cool idea. However, I'll probably just stick with these.
BTW, I like the name!



DanielB93 (author)AptPupil2015-09-23

I just purchased the same ultrasonic sensor for $.60.

Free shipping.

KegRaider (author)2014-11-08

First of all, thank you for doing this AptPupil. I definitely needed this in my garage as the old microswitch on a lever and LED was a very ugly sensor :) . After about an hour of debugging my issues, I can say that I am very happy with the result. I found that the LED's were kind of flickering during the reading for some reason, so after tweaking, and looking at Michale LeBlanc's code, I mashed the both, and changed the LED's a little bit to behave more like a visual measurement gauge.

First it lights green.
Then green and yellow1.
Then green, yellow1 and yellow2.
Then all.
Then yellow1, yellow2 and red.
Then yellow2 and red.
Then flash all.


// convert the time into a distance

inches = microsecondsToInches(duration);

if (inches > 24) {

digitalWrite(GRN_1, LOW); // No LED

digitalWrite(YEL_1, LOW);

digitalWrite(YEL_2, LOW);

digitalWrite(RED_1, LOW);


else if (inches <= 24 && inches > 18) {

digitalWrite(GRN_1, HIGH); // green LED

digitalWrite(YEL_1, LOW);

digitalWrite(YEL_2, LOW);

digitalWrite(RED_1, LOW);


else if (inches <= 18 && inches > 12) {

digitalWrite(GRN_1, HIGH); // green LED

digitalWrite(YEL_1, HIGH); // yellow LED 1

digitalWrite(YEL_2, LOW);

digitalWrite(RED_1, LOW);


else if (inches <= 12 && inches > 8) {

digitalWrite(GRN_1, HIGH); // green LED

digitalWrite(YEL_1, HIGH); // yellow LED 1

digitalWrite(YEL_2, HIGH); // yellow LED 2

digitalWrite(RED_1, LOW);


else if (inches <= 8 && inches > 6) {

digitalWrite(GRN_1, HIGH); // green LED

digitalWrite(YEL_1, HIGH); // yellow LED 1

digitalWrite(YEL_2, HIGH); // yellow LED 2

digitalWrite(RED_1, HIGH); // red LED


else if (inches <= 6 && inches > 3) {

digitalWrite(GRN_1, LOW);

digitalWrite(YEL_1, HIGH); // yellow LED 1

digitalWrite(YEL_2, HIGH); // yellow LED 2

digitalWrite(RED_1, HIGH); // red LED


// make this bit FLASH!

else {

digitalWrite(GRN_1, HIGH); // ALL LEDs ON

digitalWrite(YEL_1, HIGH);

digitalWrite(YEL_2, HIGH);

digitalWrite(RED_1, HIGH);


digitalWrite(GRN_1, LOW); // ALL LEDs OFF

digitalWrite(YEL_1, LOW);

digitalWrite(YEL_2, LOW);

digitalWrite(RED_1, LOW);



delay (100); //from mentor to stop flickering of LED's



Once again, thanks :)

ydoucare (author)KegRaider2015-04-05

That is pretty much how I did mine as well, just no blinking. I also added a button that I can use to set the preferred distance and save to EEPROM so I don't have to go back into the code to change it. I set the various LED stages to be percentages of the set point, so it scales out as you increase the distance of the set point. Lastly, I added an LCD that will display the current sensor reading as well as the set point along with a button to turn the backlight on and off.

KegRaider (author)ydoucare2015-04-06

Sounds cool ydoucare :) The Arduino community is so awesome and sharing.

ydoucare (author)KegRaider2015-04-06

Sure is! :)

KegRaider (author)KegRaider2014-11-08

Oh yeh, I have the distance values low, as I was testing from my desk and it was easy to just wave my arm towards the arduino than pushing a car around. haha!

kmarriott (author)2013-01-17

This is going to be a good project with my smARtCORE U

AptPupil (author)kmarriott2013-01-17

I spent the last 45 minutes checking it out at smARtDUINO – Do it yellow… , as well as, your Kickstarter page. Wish I had seen it in Nov.! Very cool!! I'd like more info. on your products. I'm not sure as to the method of connecting, for example, the ultrasonic sensor. Solder? Plug? Can you post a link to more info? Are you developing your own line of smARTsensors to plug in like your other pieces? I am intrigued!!

BTW, I am glad you like my project!!


kmarriott (author)AptPupil2015-03-01

You want to buy the super deluxe kit I'll sell you mine! I have a ton of extras as well. SmARtMAKER disappear from the face of the earth! No one will answer my questions and I'm still owed more parts I never got!!

Raphango (author)2013-10-29

Great ible man!

AptPupil (author)Raphango2013-10-29


Mihos (author)2013-05-10

I made something almost exactly like this a few months back, but added a motion sensor so that would sleep until I needed it. I used the 'green, yellow, red' LED method some others mentioned here as well.

AptPupil (author)Mihos2013-05-10

Cool. I've thought about adding motion to it in that way as well. Been to busy lately, though.

da83 (author)2013-01-25

Thanks alot for giving the files together in Zip file. hope others do the same.

kmarriott (author)2013-01-18

If you go to you will find everything you need to know! I am a backer of this Kickstarter project. You went to the wrong site they changed it a few weeks back. All the smARtMAKER products connect together by a bus system, there are a whack load of sensors and cpu's all Arduino compatible written in Arduino code but much easier to use. I backed this project the 1st day I seen it. Let me know what you think! I'm looking for Ideas for new projects to do with this system.

Build_it_Bob (author)2013-01-17

Very nice construction technique ...great job!

AptPupil (author)Build_it_Bob2013-01-17

Thanks Bob!

Gelfling6 (author)2013-01-17

One of my first projects, with the Arduino, was such as this, but a little less equipment.. I do like the dedicated case & extra LED's though.. the one I concepted, used just a 3 LED's, 1 each red, yellow, & green.. the concept was as soon as you got within 6 feet, it would turn on the green LED, less than 4 feet it would change to the yellow, then 2 feet the red.. Anything closer than 1 foot, all three would flash rapidly. Never got too far on it, though.. Very good design!

cawerBR (author)2013-01-17

Great idea! I will try to adapt using a buzzer to indicate how close the car is in addition to leds. This will make easier to reverse parking. Thanks for sharing. My father in law will love this device.

tolstoyan (author)2013-01-15

hi, im louie from the philippines, i am interested on doing your project, i am a beginner on the arduino and your atmega 168 is just an IC, may i ask, how will you burn the code into your IC what tool will you use?
by the way this is so cool that's why i want to build it :)

tolstoyan (author)tolstoyan2013-01-16

on the actual picture of your prototype you use 6 capacitor while in your schematic diagram you only use 5 capacitor? im confused on the missing capacitor and where to place it, and also what is its value. i also open the ArduinoParkingSpot.fzz in fritzing and it open, i also find out that it also has 1 capacitor missing. i hope you will respond on my query because i seriously want to try this project :)
by the way very great project

AptPupil (author)tolstoyan2013-01-16

Tolstoyan: Good eye. I forgot to add the 100nf capacitor to the breadboarded picture (Fritzing layout). If you follow the instructable mentioned in the intro (Perfboard Hackduino (Arduino-compatible circuit) by jmsaavedra) to build your circuit &/or look at the breadboard overlay, you will see that it goes to both chip-pins 7 & 8. It is part of the Arduino circuit. If you are using a pre-built board (Arduino Uno, Freeduino, etc), you don't need to worry. It's alraedy there. I'm not exactly sure what it does in the circuit. Someone else may be able to answer that. I will fix that a.s.a.p.


tolstoyan (author)AptPupil2013-01-16

if i am going to use a arduino uno all i need to buy is the proximity sensor, LED's and its resistor?. is the pin configuration of the ( is the same with the arduino uno? can you provide me a schematic diagram of it using an arduino uno? im worried on which pin to put in each pin, because im a beginner and im not really an arduino jockey. hope you can understand THANKS :)

AptPupil (author)tolstoyan2013-01-16

Hi Louie. Thanks for viewing & the comment! To answer your question, there are several ways to program your chip. I have an Arduino Uno & ATMega 2560. I uploaded the sketch to an ATMega 328 with bootloader while it was in the Uno board. Then I extracted the chip & placed it into the IC socket on the Perfboard Arduino (step 11 of the Perfboard Arduino 'Ible mentioned) . Here is another method that I've used before, shown on the site: From Arduino to a Microcontroller on a Breadboard. There are programmers. Many more options to program an ATMega 328 chip. Browse, and you shall find. :)

Let me know how your project turns out!

Thanks again,


danny59 (author)2013-01-14

Your Instructable is very Good. I'm in the process of designing one for my wife's car, but instead of starting from scratch, I believe I'll be using your concept. For just starting out in electronics you are very good at it. I have been teaching myself the hobby for the past two years, and people like yourself and all the others on this site have been invaluable in my learning process.
Thank you.

AptPupil (author)danny592013-01-14
Thank you so much for the kind words!! Let me know how yours turns out.

"others on this site have been invaluable in my learning process"

I couldn't have said it better myself!!

danny59 (author)AptPupil2013-01-15

You are welcome, and keep on having fun.

andrea biffi (author)2013-01-14

Great instructable! I have a pair of these ultrasonic sensors, I've to try to make this parking spotter.

AptPupil (author)andrea biffi2013-01-14

Thanks!! Let me know how it turns out!

Thiso (author)2013-01-14

wouldn't it be possible to integrate it in your car in the rear bumper? Perhaps extend to use 4 sensors?

AptPupil (author)Thiso2013-01-14

Great idea. Here's one. This guy has great knowledge and Instructables! Arduino reverse obstacle sensor for cars by liudr

mooster (author)2013-01-13

I have a tennis ball on a string in our garage, and that's fine for my purposes, but we really need something like this in public parking areas. They could sound an embarrassing alarm if anyone takes up more than one parking space, or in paid garages, perhaps they could send a signal to the check-out that will result in the person being charged double. Great!

AptPupil (author)mooster2013-01-14

Great ideas! In the meantime, check this out.

Kiteman (author)2013-01-13

I assume this fastens to the garage wall?

AptPupil (author)Kiteman2013-01-13

Thanks. I've updated the final step to say that it is to be installed on the garage wall.

AptPupil (author)Kiteman2013-01-13

Yes! Sorry. It attaches to the garage wall, which makes it stationary. This is not meant to be attached a vehicle.

About This Instructable




Bio: Jeff B. Wayne County Indiana
More by AptPupil:Arduino Ultrasonic "Parking Spotter"
Add instructable to: