When I park into my garage the space is very limited. Really. My car (a family MPV) is about 10 cm shorter than the available space. I do have parking sensors in my car but they are very limited: below 20 cm they show red alert so it is really hard to stop the car closer than 8 cm to the end of space.
My idea was to utilize an ultrasonic distance sensor for this purpose and an Arduino - of course. Sensor's usage instructions are already available in here but I'd like to get some more precise display than "too far / too close" with 2 leds. I planned a device with 7 segment led display but I started to think: this distance measurement is useful only for a few seconds then what will be in the remaining part of the day? So I added a real time clock to the system but how it will switch between time and distance display? For this purpose I added an ambient light sensor.
Step 1: Parts List
- Arduino Nano Rev3
- HC-SR04 Ultrasonic distance sensor (around $0.76)
- 7 segment 4 digit 12 pin 0.56" LED display ($1.77)
- DS3231RTC breakout board ($0.87)
- Ambient Light Sensor breakout board ($0.40)
- 2 of 74HC595N Shift register IC ($0.54 a 10 pack)
- Red LED
- Green LED
- 4 of 220 Ohm resistor
- 1 of 560 Ohm resistor
- All of the above mentioned parts are widely available in many places around the internet.
- I added the price for the specific parts based on my experience.
- The RTC breakout board is practically truly a breakout board to to let we set the time in it - e.g. in another Arduino.
- Light sensor is a cheap and simple product but already has a LM393 voltage comparator.
- 7 segment led display is a type where the anode is common, it has 12 pins, has 4 dots and a colon also. You ca use any other type as well but some modification is needed based on the pin assignments. You can find my display's schematic in the picture section of the step.
Step 2: Schematic
U1 is an Arduino Nano Rev3 but the circuit works well with Arduino Uno as well.
U2, U3: Because of the cheap led display I have to use shift registers to not eat up all my digital outputs. U2 drives the cathodes while U3 is connected to the anodes with resistors of 220 Ohm.
LED2, LED3: a green and a red leds to help the parking in a visual way. This is not necessary but could help a bit.
S1: Light sensor. When I drive into the garage - where there is no light on - my car's automatic light is getting on so with this sensor I can easily decide if the car is parking or not. If so then let's display the distance otherwise print out the time. This device has a digital output what can be high or low based on the ambient light and the trigger potentiometer's setup.
S2: Ultrasonic sensor. A really cheap one. It has a trigger and an echo pin. The usage is quite straight forward especially if you use a library designed to this purpose. I used NewPing named.
RTC1: DS3231 Real Time Clock breakout board. This is a quite precise one and has a special feature: it measures the sorrunding temperature and you can get back this information also. (With this you can work out how to display the temperature in rotation with the time.)
Step 3: Build the Circuit
I assembled the circuit on a bigger breadboard and modelled in fritzing for better understanding. I know it has a lot of cables - so I'm not able to chose different colors for all the cathode pins - bit I hope it can be sort out.
Step 4: Upload the Scratch
Here comes the source code of the device.
Step 5: Test the Result
I modelled the device on a breadboard. The lower left part you can see the ultrasonic sensor, the green led on the other cable attached device shows that ambient light sensor has the input voltage. From the second picture there are 2 green lights on on the light sensor but it is not so easy to demonstrate this with pictures. :)
There is no car in the garage. Device displays the time with not too bright numbers. Colons are blinking - together with the second decimal dot so it worth to cover the do somehow
Car is lighting to the sensor but too far to measure it. I practically set this distance to 1 meter. In this case the display shows "9999".
Car is about 10 cm from the distance sensor and lights to the light sensor. Green led shows I can go closer - carefully. :)
Car is about 5 cm from the distance sensor so red led shows that it is close enough to stop and I can close the garage door without any issue.