Garage Parking Assistant

Garage parking sensor using addressable RGB LEDs to provide feedback to vehicle driver as they approach and reach stop (park) position.

Apr 16, 2019

97957 views

129 respects

Components and supplies

1

1N4148 – General Purpose Fast Switching

1

Ultrasonic Sensor - HC-SR04 (Generic)

1

WS2812B LED Strip 1M IP30 5VDC

1

Arduino Nano R3

1

Capacitor 1000 µF

1

Through Hole Resistor, 470 ohm

Tools and machines

1

3D Printer (generic)

1

Soldering iron (generic)

Project description

Code

Arduino Code

arduino

Arduino Code

arduino

Downloadable files

Wiring Diagram

- Updated 4-21-19 to correct Diode direction

Wiring Diagram

Wiring Diagram

- Updated 4-21-19 to correct Diode direction

Wiring Diagram

Documentation

Lens

Lens

Outside Rail

Outside Rail

Case

Case

Cover

Cover

Lens

Lens

Inside Rail

Inside Rail

HoldDown

HoldDown

Ultrasonic HoldDown

Ultrasonic HoldDown

End Cap

End Cap

HoldDown

HoldDown

Case

Case

Ultrasonic HoldDown

Ultrasonic HoldDown

Outside Rail

Outside Rail

Inside Rail

Inside Rail

Cover

Cover

Comments

Only logged in users can leave comments

super-admin

a year ago

Hi sir, I’m having trouble understanding how to put the wire to the nano and the risitor as well the capacitor. The led light wire i got from amazon are confusing me. Is there any video that can help me? Thank you.

Ron1506

a year ago

Great project, many thanks for sharing your innovative use of the Arduino. I built it and used the modified code with a great result first time. The wife loves it. I didn't know why I bought the clear PLA+ in the first place, but the lenses proved my intuition correct. Thanks again Arduron.

boltonebob

2 years ago

Thank you so much for this Bcjams. Do you by chance have a version of your code that includes a timeout for times when the garage door is left open for a while? I have the project running off of a power source other than the garage door opener, as mine had no sockets.

jeboo

a year ago

https://github.com/jeboo/Garage_Parking_Assistant

Anonymous user

2 years ago

Hi Mate, would you be willing to share the model files? I'd like to make some adjustments (my components are a little bigger than expected) Please and thank you.

Anonymous user

2 years ago

Make sure that your units are set to metric when you add the objects to your software. I had the same issue when I tried to pull them in as "inches".

Anonymous user

2 years ago

If you add a push button on a digital pin (BUTTON_PIN) and ground, you can set the exact distance required, when the car is in the right position by pressing the button. The stop distance is saved in EEPROM, so power cycling the device will not change it. Of course, it needs change in the code, please, see the modified code below. I also added a timer, so that the LEDs would turn off after a configured period of time (LED_TIMEOUT), if the car is stopped (with a tolerance of DISTANCE_TOLERANCE). I cleaned up the code a bit too, so that defining NUM_LEDS is enough to change the number of LEDs, no need to add if-then-else sections to achieve that. ``` #include <FastLED.h> #include <QuickStats.h> #include <avr/eeprom.h> // not the default Eeprom.h, but the avr version !!! #include "Timer.h" QuickStats stats; Timer led_timer; #define NUM_LEDS 30 #define AMBER_LEDS 4 // number of amber LEDs when car is close to stop #define DISTANCE_TOLERANCE 3 // tolerance to determine if the car is stopped (centimeters) #define LED_TIMEOUT 120000 // in milliseconds // defining the pins #define BUTTON_PIN 6 #define LED_PIN 7 #define TRIG_PIN 9 #define ECHO_PIN 10 // defining variables CRGB leds[NUM_LEDS]; float duration; float durationarray[15]; int distance; int previous_distance; int stopdistance_ee EEMEM; int stopdistance; //parking position from sensor (CENTIMETERS) int startdistance=300; //distance from sensor to begin scan as car pulls in(CENTIMETERS) int increment=((startdistance-stopdistance)/NUM_LEDS); int incomingByte = 0; void setup() { stopdistance = eeprom_read_word (&stopdistance_ee); pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); Serial.begin(9600); } void loop() { for (int i=0;i<=14;i++) { // Clears the trigPin digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds durationarray[i] = pulseIn(ECHO_PIN, HIGH); distance= durationarray[i]*0.034/2; } duration = (stats.median(durationarray,15)); // Calculating the distance distance= duration*0.034/2; // Serial.print("stopdistance: "); Serial.println(stopdistance); // Serial.print("distance: "); Serial.println(distance); // Serial.print("previopus_distance: "); Serial.println(previous_distance); // Serial.print("led_timer: "); Serial.println(led_timer.read()); if (previous_distance-DISTANCE_TOLERANCE<distance && previous_distance+DISTANCE_TOLERANCE>distance) { if (led_timer.state() == STOPPED) { led_timer.start(); } } else { led_timer.stop(); previous_distance = distance; } if (digitalRead(BUTTON_PIN) == LOW) { stopdistance = distance; eeprom_write_word (&stopdistance_ee, stopdistance); } if (led_timer.read() > LED_TIMEOUT) { led_timer.pause(); for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Black; } } else if (distance>startdistance) { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Black; } } else if (distance<=stopdistance) { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Red; } } else { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Black; if (distance>stopdistance+increment*i) { if (i<AMBER_LEDS) { leds[i] = CRGB::Orange; } else { leds[i] = CRGB::Green; } } } } FastLED.show(); delay(50); } ```

Anonymous user

2 years ago

What Timer library are you using, i couldnt find any compatible ones.

Anonymous user

2 years ago

I'm getting this error when trying to compile the sketch: /tmp/037995901/sketch_apr21b/sketch_apr21b.ino:5:24: fatal error: QuickStats.h: No such file or directory compilation terminated. exit status 1 Am I missing something?

Bcjams

2 years ago

You need to load in the ‘QuickStats’ library to your IDE before compiling.

Anonymous user

2 years ago

Thanks, I've figured it out. I'm just starting out with Arduino, this will be my first project, so I've got some learning to do on all this compiling. I've already printed the parts, that was the easy stuff for me. I bought the Arduino to put a bootloader on one of my printers, and wouldn't you know it, here I am. Another hobby. Lol... Thanks again.

Anonymous user

2 years ago

Hi, nice idea, but where can i get this Metal Blade "Princess...". Thanks René

Anonymous user

2 years ago

Amazon. About 10$ - 12$ US

Anonymous user

2 years ago

Where can I get these 2.5 and 3mm screws that are needed? I don’t see a link in the supplies section. Thanks.

Anonymous user

2 years ago

Depends where you are. In the UK, I get most of my machine screws from RS (Components). Good choice of materials from nylon to 304 stainless. If you need a thread to be cut, try trilobar or thread cutting screws, or self-tapping screws. For really small screws, try model-making supplies.

Anonymous user

2 years ago

Author refers to 2.5-mm screws. Half sizes can be hard to find sometimes. I would use 3-mm as these are commonly used. Can't help you with length as I can't see the fixing holes. If I don't know what length is best for my projects, or it's a non-standard length, I simply buy longer screws and cut to length. I'm guessing, but as this is a printed box, it is not going to have threads cut so you might need self-tapping screws which you can't cut (hardened steel). Commercial enclosures will either use blank holes for use with self-tapping screws or the will have threaded inserts, usually brass, that press into a blank hole and give you a machine thread. Looking at an Arduino here, 3-mm would be fine. You can always open up the holes with a reamer or carefully with a drill bit. With projects like this you just have to adapt to what's available. There are always other solutions like double sided tape and PCB supports. Don't forget machine screws are measured on the overall length if countersunk, or on the threaded length if pan-head or cheese-head

Anonymous user

2 years ago

But how long do they need to be? I am in US. I see M3 screws, is that what I need?

Bcjams

2 years ago

I get all my fasteners from our local Fastenal, but you can also obtain at McMaster-Carr

Anonymous user

2 years ago

Great job! I made a very similar project, all the way down to the half rod lens haha, but I like your light style better with it split down the middle. If you use an internet connected micro, you can also add some functionality such as warning you if the garage is left open, or someone is in your space. Thanks for sharing

Anonymous user

2 years ago

It would be nice to attach a bit more photos. Especially step one and two. I am kinda lost on what goes where and how to solder leads on the LED's (where I am supposed to solder the leads).

Bcjams

2 years ago

Thanks for the feedback. Unfortunately I do not have any components to go back and take photos of at the present time. You can reference the wiring diagram, however, as the LED strip is shown in great detail and looks just like the actual strip.

Anonymous user

2 years ago

I like the idea of this project very much. I have used ping pong balls, mirrors, and other methods for parking inside my garage. However, this is the best I have ever seen. I have already found the clear half round lens mater but have not sourced the track material the LED strip lights sit in that holds the lens. I see that you have included files to print them. Is that what you did, or did you purchase them. If you did purchase the track pieces can you tell me what the source is. I don't have a 3D printer. I may be able to have a friend print the other pieces but not the tracks. Thanks.

Bcjams

2 years ago

I printed the tracks on my 3d printer. I designed it to fit on most printers, as most have 200x200mm or larger build platforms.

christopher_haresnape

2 years ago

Beautiful.

Anonymous user

2 years ago

Hello very good Idea , but i have one problem with the function , i have installed the newest Arduino IDE , with FastLED and Quickstats , the Problem is she doesn't work... Can you tell me which arduino IDE , FastLED and Quickstats version you use. thank you best regards Alex

Anonymous user

2 years ago

I found the Error , one LED Stripe was in to the false direction. best regards alex

Anonymous user

2 years ago

Nice project, but how can i adjust the distance thanks

Bcjams

2 years ago

You will need to modify the parameters in Lines 18 and 19. See the comments on those two lines for definition/explanation.

Anonymous user

2 years ago

Great project! I just got my parts back from the 3D printer and I have a question about the part labeled HoldDown. I assume it must go on the Arduino, but can't quite figure out where. Do you have an explanation or maybe some photos to show how they fit together? Thanks

Anonymous user

2 years ago

Thanks for the photos they really help.

Bcjams

2 years ago

Danny, I have uploaded the build photos to the key project steps.

Bcjams

2 years ago

Danny, I apologize. I just realized I had forgotten to upload some of the build photos. I don’t have access to my computer right now, but will upload these photos in a few hours. In the meantime, you can go to Thingiverse website and search “bcjams garage” and the project will show up there with photos of the build.

Anonymous user

2 years ago

Bcjams: Have finished project and am would like to include a video of my setup in action. How can I post the video and maybe you can take a look at it and give me your opinion as to what adjustments I might have to make. Thanks again

Anonymous user

2 years ago

Bcjams: Having trouble with my leds just turning on red when object is close to sensor. I just want to be sure I understand the part of the code that defines the number of leds. Is the number defined the number of leds on each side or a total number of leds in the project? Thanks

Bcjams

2 years ago

The way the code works is the lED’s are mirrored left side and right side , so whatever happens to right will be same on left. The Led’s are numbered 0 through 14 (15 leds in total, with the 0 position closest to control box. As you read through code you will see at maximum range all LED’s are green. As an object approaches the ‘stopdistance’ lights at outer ends turn off. As object moves even closer, anybremaing lights will begin turning yellow and continue turning off sequentially until only one remains lit on either side of center. As soon as object reaches stopdistance all lights turn on red. If objects continue to get closer all red lights remain on. You can change program any way you would like as you because familiar with programming. One thing you could do is have all lights flash red if object continues to move past the stop distance. Anything is possible. You would do no harm by experimenting which is half the fun of the project.

Anonymous user

2 years ago

Hello again Bcjams, I am trying to assemble all of the electronics into the case, but am having trouble with the capacitor. I ordered one from Newark but it has not come yet, all of the other parts came ok. The info on the capacitor from Newark is: ECA-1EM102. - Electrolytic Capacitor, 1000 µF, 25 V, M Series, ± 20%, Radial Leaded, 10 mm. So I took this information to Mouser ( I am close enough to do a will call from them) I used the same information from Newark, but the capacitor is a bit too long to fit into the space inside the case. Did you use a different capacitor? The one you show in the picture looks different from the one I have from Mouser. Also if I powered the Arduino from the USB connector and wired the LEDs directly from the 5v on the Arduino, would I still need the capacito? Thanks in advance for your help. Danny

Anonymous user

2 years ago

I picked up a 100uF capacitor from Mouser MFG P/N: ECA-1EHG101I, so do you think this will be sufficient to use (it is much smaller and will fit in case)? Thanks

Anonymous user

2 years ago

Danny - you are being too cautious. Try it and see. Manufacturers quite often over-specify things to be on the safe side. Put in as much capacitance as will fit, but it will probably be overkill. Too much though can cause problems of large inrush currents when you power up. Go for 100uF. When you get into Farad sized capacitors, then that's big.

Anonymous user

2 years ago

Not my project, but capacitor is not normally critical unless calculated necessary. A minimum on anything digital might be 10uF electrolytic with 0.1uF ceramic in parallel. You can safely add 0.1uF across the power lines of any IC, as close as possible. A 470uF would probably work OK or two 470uF in parallel to give ~ 1000uF Arduino Uno and Mega have two 47uF already on the board, but Nano has nothing that large, 6u7F on my schematic, so anything larger would help

Bcjams

2 years ago

Phil-S, thanks for your input. I used the 1000uF based on protecting the RGB strip, not necessarily the Arduino. This was gathered as recommendations I had seen for using RGB strips. I agree with you that it may not be necessary, but I would rather be on the safe side. After reviewing this again, I do see that recommendations were to use capacitor values between 100uF and 1000uF. The 100uF will be much smaller in size, so that would be another good option.

Bcjams

2 years ago

Should work fine. Let me know how your build goes!

Bcjams

2 years ago

The capacitor I used was a 16V rating, which is smaller in size than the 25V. I had gotten this through a capacitor assortment kit I had purchased on Alibaba. The capacitor is there to prevent potential spikes from power supply. The exact value is not that critical, so I would find one as close to 1000uF as possible that will fit down inside case. You can't connect LED's directly to Arduino, as the LED's pull more current than the Arduino voltage regulator can supply. If you cant find right size capacitor, another option would be to wire the capacitor you have on external power leads coming into the unit.

lastguy

2 years ago

Nice to see a great project and thanks! It might be better if principle is described - which I guess is that using ultrasonic to detect distance then change LED? if car drives too left or too right what would happen? my garage is bit narrow so I want the direction is correct. It is easier for parking distance as driver can put sth near his window as flag, or even hang down a strip when car hit it means stop. Suppose your garage door is no more than one feet of car width. Hope somebody can comment.

richards52536

2 years ago

Pleased to see your issue as I think I have the same problem

Anonymous user

2 years ago

Great project. How did you calculate capacitor and resistor? Regards Mike

Anonymous user

2 years ago

Is there a way to setup a pot for adjustment and possibly a button to record the current cars position?

Bcjams

2 years ago

To add pots and switches, all you would need to do is connect them to some unused pins and use these to set the ‘startdistance’ and ‘stopdistance’. You can google this to find examples of how to make variables set using pots and switches. Sorry, but I don’t currently have the time to write some example code for this. Packaging these might be a bit tricky, as there is not much room inside the control box to add more wiring. If you have access to create your own Cad models, a suggestion would be to add a spacer ring under the top cover (where ultrasonic sensor is mounted).

Anonymous user

2 years ago

This is really cool. What is everyone doing for power? I dont want to run a wire all the way to the garage door but also dont want this thing on all the time the car is parked

Anonymous user

2 years ago

Hello, I will be making this project, I just need to know, how many amps does the transformer use for the 120VAC to 5v DC?

Anonymous user

2 years ago

Which transformer? The author would be best place to answer your question, but it looks from the schematic that the circuit uses a plugtop (wallwart?) or pluggable power supply. These can be unregulated, regulated or Switched Mode. The schematic shows 5-V DC being fed into the Vin on the Nano and also feeding the 30 LEDs. Introducing a diode (1N4148) drops the voltage further. The 1N4148 is a signal diode and really needs to be beefier like a 1N4001, or better, a Schottky The Nano 5-V regulator fed from Vin really needs more than 5-V to work properly, more like 9-V. As an estimate, take 30 x 20-mA for the LEDs, add on the Nano consumption from the datasheet, same for the sensor. Add on a 50% overhead for safety. This will be the current at 5-V DC. At a guess, 1-Amp at 5-V would be adequate. If I were doing this, I might start with a 9-V DC power supply, supply this to Vin on the Nano and use a separate 5-V regulator for everything else. Don't put voltage into the pin marked 5V on the Nano - this is an output from the regulator. If you have access to a multi-meter or a bench power supply, you can see the actual current being used.

Anonymous user

2 years ago

Hi, I just noticed a slight (possible?) error in the code, whereby 2 of the green LEDs turn off at the same time as the car approaches, maybe this is how you wannted it? In this part of the code: if (distance<stopdistance+increment*9){ for (int i = 9; i <= 14; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 9; i++) { leds[i] = CRGB ( 0, 255,0); To make the LEDs turn off one by one as the car approaches, change: for (int i = 0; i <= 9; i++) { to: for (int i = 0; i <= 8; i++) { Hope this helps. Also i am interested in having the whole thing powered up all the time as i want to put the LED strips on the wall outside on the driveway, not in a garage. Therefore i need the project powered all the time, to stop the LEDs being Green all the time i have changed the final line so that if the car is greater than say 100cm away, no LEDs will be lit: else if (distance>=stopdistance+increment*14){ for (int i = 0; i <= 14; i++) { // leds[i] = CRGB ( 0, 255,0); - original code so that green is always shown leds[i] = CRGB ( 0, 0, 0); //new code so that all LEDs are off } FastLED.show(); delay(50); But how do i easily add some kind of timer to say if the LEDs have been in a steady state (ie the distance not changing) for greater than say 2 minutes, the LEDs will shut off. Also i want it so that if someone gets in the car and starts to back out or go forward the LEDs come back on, any ideas? Thanks!

Anonymous user

2 years ago

I used a photoresistor in a straw aimed at the lights of the garage door opener. The lights turn ON for a set time after opening so I have the LED strip disabled if no lights are detected.

Bcjams

2 years ago

Thanks for the catch! I updated the code accordingly. If you have the LED's outside, I would recommend you make sure the RGB strip is waterproof. The ones I used are not waterproof, but they do offer them. As far as how to turn off after 2 minutes, that should be achievable. You would need to setup a counter in the loop that would look for state of change. Anytime change is seen, counter would reset to zero. If counter reaches 2 minutes, the lights turn off. If someone gets in the car again, lights would come back on because it would see change of state (distance) once again. The only problem I see with this, however, is that the HC-SR04 appears to be sensitive to random signals (which is why I used a Median Value calculation to throw out random signals), so you may end up with lights turning on and off throughout the day. If you keep the calculation for change of state lenient (maybe with about 10cm?), it might have a good chance of success. Good Luck!

Anonymous user

2 years ago

Thanks, I have noticed that the reading from the sensor varies quite a bit when just pointing at a wall with no movement inbetween, so as you say i dont think ill get a few minutes whereby the reading remains steady enough for a couter to reach 2 mins. I am thinking of using a standard PIR sensor which would detect heat/motion from a car, then wire the +5v supply to the LEDs from this.

Anonymous user

2 years ago

Great project, will be looking to use some of this in my build of a parking light on the garage door when parking in the driveway. P.S. The diode in the wiring diagram is round the wrong way

Bcjams

2 years ago

Ah, good catch! I will update the wiring diagram when I get back to my computer! Thank you!

Anonymous user

2 years ago

Looks like a good idea and well implemented. What did catch my eye was the threat of violators being "toad", or was that meant to be "frogged"? A well tried "old tech" method used to be to suspend a ping pong ball from the ceiling in such a position that it just touched the windscreen when the vehicle was at the correct distance.

Anonymous user

2 years ago

Your project is super. 'FastLED' is only available in libraries and I installed it but 'QuickStats' ,'startdistance' and 'stopdistance' is not available what's the solution for it please reply me soon

Anonymous user

2 years ago

I found Quickstats through a Google search. 'startdistance' and 'stopdistance' are program variables that are define in the top of the program. You don't need to do anything with them other than set your distances.

Anonymous user

2 years ago

Awesome project my friend :) Quick question how can i modify this using a 3 car garage?? ...What i am thinking is one Arduino (the brain) and 3 sonic sensors wired in parallel do you think that will work ?? Meaning that if one of the sensors has a car moving and obviously in the garage only one car can enter at a time than the whole strip will light up accordingly.??? But that brings me to thinking that lets say that the parallel sensor thing works than what happens if there are other cars already parked ??? how can i modify the code than that 3 sonic sensors act independently ?? Oh another question ...i have all the other parts but an Arduino Uno instead of your Nano R3 will it work with Uno?? Thank you again

Bcjams

2 years ago

It would be a challenge to get this particular design modified to incorporate three garage doors. Just trying to wire three sensors within the case would not be feasible due to case size. Also, it would be challenging (but not impossible) to determine status of the other two vehicles (whether or not they are present and already parked. If it were me, I would just have three individual light bar assemblies, one for each door. I think my total cost per unit was less than $8.

Anonymous user

2 years ago

Hi I am gald to see your design, some questions about the arudino. 1.I just find out the FastLED data in the arudino library, and I saw the information in comments. So I find the file for QuickStats and make it zips file and add it into the library. Once I inserted the QuickStats files and that showed some .h files, and the FastLED.h change to red color. Could you have some idea what's going on? Any idea how to deal with these problem? I really appreaciate that. With regards.

Anonymous user

2 years ago

I have the same problem have you solved it? Thx so much

Anonymous user

2 years ago

Hi can some body send me pic how connect all i have problem. I want Just use it all Time on at Time dorrs is opening. When i did it i burn 2 aruinos so please send me how connect all thanks

Anonymous user

2 years ago

Hi! I'm doing the project but I have some problems, one is about the code, it says that and I would like to know how to solve it. Thx so much, your project it's amazing! In file included from /Users/macbookpro/Documents/Arduino/libraries/FastLED/noise.h:4:0, from /Users/macbookpro/Desktop//Proyecto_v1_1/Proyecto_v1_1.ino:1: /Users/macbookpro/Documents/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.002 # pragma message "FastLED version 3.003.002"

Anonymous user

2 years ago

Bcjams: I have all the components installed (not in the case) and doing test on the entire system. I get a constant stream of red leds, so I thought maybe I had some problem with the sensor settings so I changed the code to: int stopdistance=75; //parking position from sensor (CENTIMETERS) int startdistance=150; //distance from sensor to begin scan as car pulls in(CENTIMETERS) . This doesn't work either. Any suggestion as to what changes to try? Thanks

Bcjams

2 years ago

With Arduino connected to USB, open up a serial monitor window. The distance will be displayed. If it outputs only 0’s, that would indicate a wiring or sensor issue. Otherwise it will give you distance in cm.

Bcjams

2 years ago

Great to hear that you have it working! You are on track with going for the stranded wire. I use silicone 22 AWG wire which is sufficient for the current and is. very flexible. It is a tight package to wire up, but very doable if you are careful and patient. Also plan ahead with where you want to splice your wiring to branch off to the various points of connection. I created the primary splices and tucked them under the Arduino.

Bcjams

2 years ago

Danny, with the output reading 30 (cm) all red LEDs will be on, as you had changed your stop distance to 75 per a previous message post. Is there anything partially blocking your ultrasonic? They have a 15 degree window I believe, so if it is sitting on a bench it may be getting a reflection. Try holding the sensor away from objects to see if value changes. It could be a faulty sensor. I would recommend you try reloading the original code (without edit) to see what happens. Once you get it working you can edit the start/stop distances. The code is well tested (I have built two of these with no issues).

Anonymous user

2 years ago

For really fine wire, try any of the following. Ethernet cable like CAT5e has 8 cores of solid insulated wire. Wire-wrapping wire is also solid, but very fine. Alarm cable, stranded, very flexible, get 8 cores of coloured wires. On the subject of components, it usually pays to start with branded items from people like Adafruit, Sparkfun etc., or mainline distributors like RS and Farnell. Amazon and eBay are awash with clones and cheap copies. Some work and some don't. Plus you won't get any support. Elegoo do very good versions of Uno, Nano and Mega at a fraction of Arduino prices, but Arduino does rely on product sales to maintain the project as a whole.

Anonymous user

2 years ago

Have changed the sensor and this is what I see on the serial monitor: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 What would you suggest I check at this point? Thanks

Anonymous user

2 years ago

Thanks Phil-S, I appreciate all of your input it has been very helpful. I am on a track to get this project completed. It may take me longer since I don’t have all the knowledge, but I am a fast learner and persistent. I enjoy the challenge of a project of this caliber and will celebrate in its completion.  Thanks again for your input.  

Anonymous user

2 years ago

Ok now I have added the 5v power and connected the USB to the serial port and this is what I see: 31 30 30 30 30 30 31 30 31 31 31 30 31 31 30 Distance: 30 31 30 31 30 31 31 31 31 31 31 31 31 31 31 31 Distance: 31 31 30 31 30 30 30 30 30 31 30 30 31 31 31 31 Distance: 30 30 31 30 31 30 30 30 30 30 30 30 30 30 30 30 Distance: 30 31 31 30 30 30 30 30 30 30 30 31 30 31 31 30 Distance: 30 30 30 30 31 30 30 30 30 30 30 30 30 30 31 31 Distance: 30 30 31 30 30 30 30 30 30 31 30 30 31 31 31 31 Distance: 30 30 31 30 31 31 31 30 31 31 30 31 31 31 31 30 Distance: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 Distance: 31 30 30 30 30 31 31 30 30 30 31 30 30 31 30 31 Distance: 30 31 31 30 31 31 31 31 31 31 30 30 30 30 31 30 Distance: 31 32 31 31 31 31 32 31 32 31 32 31 32 32 32 32 Distance: 32 2225 2225 2225 2225 37 37 37 37 37 37 37 36 36 36 36 Distance: 37 I don't see any leds turning on or off.????

Anonymous user

2 years ago

Not seeing anything on serial monitor. I will check wiring again and sensor. Just a quick question about the diode, in your schematic it appears that the thin black line points toward the connection to the Arduino from the power source, is that correct? Thanks

Anonymous user

2 years ago

I did get it to work after changing the sensor. I am having trouble now after assembling all the parts. There is so little room with all the wires even after installing the capacitor outside the box. I have been using solid wire, I am going to redo the wiring with stranded wire and see if I can get everything into the case and have it to function after closing the case. Thanks for your help and encouragement. Danny PS I will keep you posted.

Anonymous user

2 years ago

Is this your first project with ultrasonics? If it is, I would take a step back and try a simple project with with just the sensor (try the Arduino Playground) or a tutorial (must be loads of them online - any robotics project will do) just to get your confidence back, then work up to the full LED thing. If the code is good and tested, then it most likely is going to be in the wiring. Have you changed any pins or settings/variables in the code. It looks as though changing the power supply arrangements has done something. What you have omitted to say is how are you testing the setup. I would stop and check everything, especially power, before something starts smoking. It's a reasonably complex project and quite easy to get something wrong. All those LEDs lit up at once could seriously pull power down.

Anonymous user

2 years ago

The diode is in the positive supply line to the Nano to protect against reverse connection. The 1N4148 is a glass bodied diode and the black band denotes the cathode and in this application, the cathode points towards the equipment being powered, the Nano. Personally, I might use a diode with a higher current rating like a 1N4001. These are black plastic bodied with a silver or white band. You might need to add some lines of Serial.print in the loop and setup to see where it's stalling. Make sure your comms baud rates are the same in the monitor and in the code. 9600 is a good choice. Also, line end should be the default "New line"

Anonymous user

2 years ago

I'm trying to make this one. I'm using 2 strips with 30 LEDs each, and I've modified the line #define NUM_LEDS 15 to #define NUM_LEDS 30 but even with this mod there are only 15 LEDs working in each strip. Can you please advise what might be needed to light up the 30 LEDs in each side? Thanks! Eduardo

Anonymous user

2 years ago

There is an IF statement in the code that walks down through the LEDs. If you change the number of LEDs then you need to modify that IF statement and add enough ELSE IF's for the number of LEDs you have.

Anonymous user

2 years ago

I have just completed this project. My first one to be exact. Thank you for all your hard work. I hope you will continue making videos/projects for us all. Thanks again. Felix C

Anonymous user

2 years ago

I also made one with some tricks, but it works now. I still have to hang it. That is the last job.

Anonymous user

2 years ago

Hello, What power supply will be good for this project? The 5V 5A will be good enough?

procyon78

2 years ago

Correct, a 5A power supply is more than enough. Each LED can draw 20mA at maximum light intensity for each colour, so your maximum rating is 20mA x 3 colours x 30 LEDs = 1.8 Amps

Anonymous user

2 years ago

I just wanted to let you know that I am also working on this project. I got my parts yesterday and had it up and running in about an hour. I bought a 60 led strip instead of the 30 led strip you used, so I had to modify the code a little, and I change a few things while I was in there as well. Overall, this is coming together nicely. I plan on wiring the power up to mine a little different as well, just to satisfy another condition of the door I need to monitor. I am hoping to also use a couple of buttons to set start/stop distance as well, as another poster had mentioned. I will keep you updated on how all that goes.

Anonymous user

2 years ago

I have mostly completed the project. I ended up not putting in a range pot or anything, mainly because I can't think of needing to adjust it that often, and there is so little room in the enclosure. Since our van barely fits in our garage, I mounted a switch on the door rail to sense when the door is fully open. I ran the power to the sensor through this, so when the door is open, the circuit will power up and the leds will light up to let us know that it is safe to back the van out, or pull the van in. The only issue with this is if we leave the garage door open, then the leds will remain. I need to put some some code in to detect a "sleep" period after the power has been on for a certain amount of time.

Anonymous user

2 years ago

Good luck will be watching your progress.

Anonymous user

2 years ago

Love the sign.

Anonymous user

2 years ago

Very nice project. Thx a lot.

Anonymous user

2 years ago

Any reason to not use the usb for the power? Thank you

Anonymous user

2 years ago

Great project/idea! After constructing the original design and then reviewing the code, I decided to make some improvements. First, the post by galmiklos had an excellent revision of the code to add a sleep feature (if power not tied to opener) and support any # LEDs. Unfortunately the timer library used in his revision doesn't appear to be in the Arduino library. I went ahead and updated it to use a publically available library, and also made some minor revisions. I added 2 new options, the first being a slower polling frequency when in sleep mode. The second was separation of the left and right LED strips for potential customization. This would allow different colors, animations, wig-wag flashing or anything you can come up with. The code could be further optimized, but I left it as is for simplicity/readability. The version I'm posting here is fully compatible with the original project design. I did end up designing a custom PCB and 3D-printable housing as well, let me know if you want a copy. https://github.com/jeboo/Garage_Parking_Assistant ``` /* Garage Parking Sensor * * Original code by Bob Torrence -- https://create.arduino.cc/projecthub/Bcjams/garage-parking-assistant-11446b * Major revision by galmiklos (added eeprom storage for stop distance set by button, added sleep feature, optimized code for any # LEDs) * Additional optimizations/features by jeboo * * Version history: * 0.5 -- Switched timer library to MillisTimer (galmiklos code appeared to use customized/unavailable library) * Fixed push-button setting for stopdistance: can still specify static value; setting via button no longer requires a reboot * Added option (SLEEP_POLLDELAY) to poll less often once in sleep mode * Added option for independent left and right LED strip control; allows differing colors, animations, etc. * * 0.6 -- Added EEPROM dependency and switched to QuickMedianLib for compatibility with megaAVR boards (tested on Nano Every). */ #include <FastLED.h> #include <MillisTimer.h> #include <EEPROM.h> #include <QuickMedianLib.h> // defining the parameters/layout #define NUM_LEDS 15 // # LEDs on each side #define AMBER_LEDS 4 // number of amber LEDs when car is close to stop #define DISTANCE_TOLERANCE 3 // tolerance to determine if the car is stopped (CENTIMETERS) #define LED_TIMEOUT 60000 // in milliseconds, time before lights go out (sleep) once car stopped #define SLEEP_POLLDELAY 1000 // in milliseconds, delay for each main loop iteration while in sleep mode // defining the pins #define BUTTON_PIN 6 // push-button for setting stopdistance (optional) #define LED_PIN_L 7 // left-sided LEDs (or both sides if mirror_LEDs set to true) #define LED_PIN_R 8 // right-sided LEDs (optional), implemented by setting mirror_LEDs below to false #define TRIG_PIN 9 #define ECHO_PIN 10 // defined variables int startdistance = 395; // distance from sensor to begin scan as car pulls in (CENTIMETERS); HC-SR04 max distance is 400CM int stopdistance = 0; // parking position from sensor (CENTIMETERS); either specify here, or leave as zero and set dynamically with push-button const int durationarraysz = 15; // size of array for distance polling bool mirror_LEDs = true; // true = L + R LEDs controlled by pin 7 (mirrored, as in stock project) // variables CRGB leds_L[NUM_LEDS], leds_R[NUM_LEDS]; float duration, durationarray[durationarraysz]; int distance, previous_distance, increment, i; uint16_t stopdistance_ee EEMEM; MillisTimer timer = MillisTimer(LED_TIMEOUT); bool LED_sleep; void sleepmode_start(MillisTimer &mt) { for (i = 0; i < NUM_LEDS; i++) { leds_L[i] = leds_R[i] = CRGB::Black; } FastLED.show(); timer.reset(); LED_sleep = true; } void setup() { LED_sleep = false; if (!stopdistance) { stopdistance = eeprom_read_word(&stopdistance_ee); } increment = (startdistance - stopdistance)/NUM_LEDS; pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); FastLED.addLeds<WS2812, LED_PIN_L, GRB>(leds_L, NUM_LEDS); if (!mirror_LEDs) { FastLED.addLeds<WS2812, LED_PIN_R, GRB>(leds_R, NUM_LEDS); } timer.setInterval(LED_TIMEOUT); timer.expiredHandler(sleepmode_start); timer.setRepeats(0); Serial.begin(9600); } void loop() { timer.run(); for (i = 0; i < durationarraysz; i++) { // Clears the trigPin digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds durationarray[i] = pulseIn(ECHO_PIN, HIGH); } duration = QuickMedian<float>::GetMedian(durationarray, durationarraysz); // Calculating the distance distance = duration*0.034/2; //Serial.print("stopdistance: "); Serial.println(stopdistance); //Serial.print("distance: "); Serial.println(distance); //Serial.print("previous_distance: "); Serial.println(previous_distance); // check if distance changed is within tolerance if (abs(distance - previous_distance) < DISTANCE_TOLERANCE) { if (!timer.isRunning() && !LED_sleep) { timer.start(); } } else // movement beyond threshold, stop timer and turn off sleep { previous_distance = distance; timer.reset(); LED_sleep = false; } // check button state if (digitalRead(BUTTON_PIN) == LOW) { stopdistance = distance; eeprom_write_word(&stopdistance_ee, stopdistance); increment = (startdistance - stopdistance)/NUM_LEDS; } if (!LED_sleep) { if (distance > startdistance) { for (i = 0; i < NUM_LEDS; i++) { leds_L[i] = leds_R[i] = CRGB::Black; } } else if (distance <= stopdistance) { for (i = 0; i < NUM_LEDS; i++) { leds_L[i] = leds_R[i] = CRGB::Red; } } else { for (i = 0; i < NUM_LEDS; i++) { if (distance > (stopdistance+increment*i)) { leds_L[i] = leds_R[i] = (i < AMBER_LEDS) ? CRGB::Orange : CRGB::Green; } else { leds_L[i] = leds_R[i] = CRGB::Black; } } } FastLED.show(); delay(50); } else { delay(SLEEP_POLLDELAY); } } ```

rbh87

2 years ago

Is there a way to make the LEDs go from green to amber to red the closer the object gets?

Anonymous user

2 years ago

hello, i am newbe whit arduino, because this project is so good explained i want to try making this one because i have some parts to do this, only i have WS2812B RGB / 60 LED / meter and i changed this, #define NUM_LEDS 30 but i can't get the leds to work, must i do more ? I SEE ONE COMMENT LIKE THIS AND THE ANWER ¨^ modify that IF statement and add enough ELSE IF's for the number of LEDs you have , can someone help me plz

Anonymous user

2 years ago

I was a bit hopeless at first but after checking everything I learned something, everything works perfectly and I was able to solve it myself, thanks anyway for thinking along to find a solution

Anonymous user

2 years ago

I posted the code for a 30 light LED. hope it helps

Anonymous user

2 years ago

[code] /* * Garage Parking Sensor - Published By Bob Torrence */ #include <FastLED.h> #include <QuickStats.h> QuickStats stats; //initialize an instance of this class // defining the pins #define LED_PIN 7 #define NUM_LEDS 30 const int trigPin = 9; const int echoPin = 10; // defining variables CRGB leds[NUM_LEDS]; float duration; float durationarray[30]; int distance; int stopdistance=115; //parking position from sensor (CENTIMETERS) int startdistance=400; //distance from sensor to begin scan as car pulls in(CENTIMETERS) int increment=((startdistance-stopdistance)/15); void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); Serial.begin(9600); // Starts the serial communication } void loop() { for (int i=0;i<=29;i++){ // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds durationarray[i] = pulseIn(echoPin, HIGH); distance= durationarray[i]*0.034/2; Serial.print(distance); Serial.print(" "); } duration = (stats.median(durationarray,30)); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); if (distance<stopdistance){ for (int i = 0; i <= 29; i++) { leds[i] = CRGB ( 255, 0, 0); FastLED.show(); } } else if (distance<stopdistance+increment){ for (int i = 1; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 0; i++) { leds[i] = CRGB ( 255, 255, 0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*2){ for (int i = 2; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 1; i++) { leds[i] = CRGB ( 255, 255, 0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*3){ for (int i = 3; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 2; i++) { leds[i] = CRGB ( 255, 255, 0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*4){ for (int i = 4; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 3; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*5){ for (int i = 5; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 4; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*6){ for (int i = 6; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 5; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*7){ for (int i = 7; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 6; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*8){ for (int i = 8; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 7; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*9){ for (int i = 9; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 8; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*10){ for (int i = 10; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 9; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*11){ for (int i = 11; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 10; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*12){ for (int i = 12; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 11; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*13){ for (int i = 13; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 12; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*14){ for (int i = 14; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 13; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*15){ for (int i = 15; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 14; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*16){ for (int i = 16; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 15; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*17){ for (int i = 17; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 16; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*18){ for (int i = 18; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 17; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*18){ for (int i = 18; i <= 298; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 17; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*19){ for (int i = 19; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 18; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*20){ for (int i = 20; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 19; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*21){ for (int i = 21; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 20; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*22){ for (int i = 22; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 21; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*23){ for (int i = 23; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 22; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*24){ for (int i = 24; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 23; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*25){ for (int i = 25; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 24; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*26){ for (int i = 26; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 25; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*27){ for (int i = 27; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 26; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*28){ for (int i = 28; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 27; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*29){ for (int i = 29; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 28; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } } [/code]

Anonymous user

2 years ago

Great project! I completed the project and it is working as advertised except for the "off" feature. It usually goes into sleep mode, but then comes back on and blinks randomly. The problem appears to be the distance sensor's accuracy. The sound appears to bounce off the front grill of the car erratically. If a piece of cardboard is placed in between, the device shuts off and stays off. Any recommended tweaks to programming language or other fix? Anyone's help will be greatly appreciated.

Anonymous user

2 years ago

Congrats on completing it! If you are getting sporadic reactivation while parked, I would check the height of the sensor. See where it's hitting the bumper and possibly try to move it up/down to a more stable position (i.e., bumper rather than the grill). This should hopefully cut down on the noise as it's hitting a nice solid surface. Be sure to recalibrate the stop distance once you find a sweet spot! If you're using my updated version of the script, you can also try increasing '#define DISTANCE_TOLERANCE' until it stops detecting movement. The default is 3cm, which is just over an inch.

Anonymous user

2 years ago

What program did you use to design the circuit? I am trying to use tinkercad but can't find the components

Anonymous user

2 years ago

Great project! I completed the project and it is working as advertised except for the "off" feature. It usually goes into sleep mode, but then comes back on and blinks randomly. The problem appears to be the distance sensor's accuracy. The sound appears to bounce off the front grill of the car erratically. If a piece of cardboard is placed in between, the device shuts off and stays off. Any recommended tweaks to programming language or other fix? Anyone's help will be greatly appreciated.

jeboo

2 years ago

Congrats on completing it! If you are getting sporadic reactivation while parked, I would check the height of the sensor. See where it's hitting the bumper and possibly try to move it up/down to a more stable position (i.e., bumper rather than the grill). This should hopefully cut down on the noise as it's hitting a nice solid surface. Be sure to recalibrate the stop distance once you find a sweet spot! If you're using my updated version of the script, you can also try increasing '#define DISTANCE_TOLERANCE' until it stops detecting movement. The default is 3cm, which is just over an inch.

Anonymous user

3 years ago

I have just completed this project. My first one to be exact. Thank you for all your hard work. I hope you will continue making videos/projects for us all. Thanks again. Felix C

jeboo

3 years ago

Great project/idea! After constructing the original design and then reviewing the code, I decided to make some improvements. First, the post by galmiklos had an excellent revision of the code to add a sleep feature (if power not tied to opener) and support any # LEDs. Unfortunately the timer library used in his revision doesn't appear to be in the Arduino library. I went ahead and updated it to use a publically available library, and also made some minor revisions. I added 2 new options, the first being a slower polling frequency when in sleep mode. The second was separation of the left and right LED strips for potential customization. This would allow different colors, animations, wig-wag flashing or anything you can come up with. The code could be further optimized, but I left it as is for simplicity/readability. The version I'm posting here is fully compatible with the original project design. I did end up designing a custom PCB and 3D-printable housing as well, let me know if you want a copy. https://github.com/jeboo/Garage_Parking_Assistant ``` /* Garage Parking Sensor * * Original code by Bob Torrence -- https://create.arduino.cc/projecthub/Bcjams/garage-parking-assistant-11446b * Major revision by galmiklos (added eeprom storage for stop distance set by button, added sleep feature, optimized code for any # LEDs) * Additional optimizations/features by jeboo * * Version history: * 0.5 -- Switched timer library to MillisTimer (galmiklos code appeared to use customized/unavailable library) * Fixed push-button setting for stopdistance: can still specify static value; setting via button no longer requires a reboot * Added option (SLEEP_POLLDELAY) to poll less often once in sleep mode * Added option for independent left and right LED strip control; allows differing colors, animations, etc. * * 0.6 -- Added EEPROM dependency and switched to QuickMedianLib for compatibility with megaAVR boards (tested on Nano Every). */ #include <FastLED.h> #include <MillisTimer.h> #include <EEPROM.h> #include <QuickMedianLib.h> // defining the parameters/layout #define NUM_LEDS 15 // # LEDs on each side #define AMBER_LEDS 4 // number of amber LEDs when car is close to stop #define DISTANCE_TOLERANCE 3 // tolerance to determine if the car is stopped (CENTIMETERS) #define LED_TIMEOUT 60000 // in milliseconds, time before lights go out (sleep) once car stopped #define SLEEP_POLLDELAY 1000 // in milliseconds, delay for each main loop iteration while in sleep mode // defining the pins #define BUTTON_PIN 6 // push-button for setting stopdistance (optional) #define LED_PIN_L 7 // left-sided LEDs (or both sides if mirror_LEDs set to true) #define LED_PIN_R 8 // right-sided LEDs (optional), implemented by setting mirror_LEDs below to false #define TRIG_PIN 9 #define ECHO_PIN 10 // defined variables int startdistance = 395; // distance from sensor to begin scan as car pulls in (CENTIMETERS); HC-SR04 max distance is 400CM int stopdistance = 0; // parking position from sensor (CENTIMETERS); either specify here, or leave as zero and set dynamically with push-button const int durationarraysz = 15; // size of array for distance polling bool mirror_LEDs = true; // true = L + R LEDs controlled by pin 7 (mirrored, as in stock project) // variables CRGB leds_L[NUM_LEDS], leds_R[NUM_LEDS]; float duration, durationarray[durationarraysz]; int distance, previous_distance, increment, i; uint16_t stopdistance_ee EEMEM; MillisTimer timer = MillisTimer(LED_TIMEOUT); bool LED_sleep; void sleepmode_start(MillisTimer &mt) { for (i = 0; i < NUM_LEDS; i++) { leds_L[i] = leds_R[i] = CRGB::Black; } FastLED.show(); timer.reset(); LED_sleep = true; } void setup() { LED_sleep = false; if (!stopdistance) { stopdistance = eeprom_read_word(&stopdistance_ee); } increment = (startdistance - stopdistance)/NUM_LEDS; pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); FastLED.addLeds<WS2812, LED_PIN_L, GRB>(leds_L, NUM_LEDS); if (!mirror_LEDs) { FastLED.addLeds<WS2812, LED_PIN_R, GRB>(leds_R, NUM_LEDS); } timer.setInterval(LED_TIMEOUT); timer.expiredHandler(sleepmode_start); timer.setRepeats(0); Serial.begin(9600); } void loop() { timer.run(); for (i = 0; i < durationarraysz; i++) { // Clears the trigPin digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds durationarray[i] = pulseIn(ECHO_PIN, HIGH); } duration = QuickMedian<float>::GetMedian(durationarray, durationarraysz); // Calculating the distance distance = duration*0.034/2; //Serial.print("stopdistance: "); Serial.println(stopdistance); //Serial.print("distance: "); Serial.println(distance); //Serial.print("previous_distance: "); Serial.println(previous_distance); // check if distance changed is within tolerance if (abs(distance - previous_distance) < DISTANCE_TOLERANCE) { if (!timer.isRunning() && !LED_sleep) { timer.start(); } } else // movement beyond threshold, stop timer and turn off sleep { previous_distance = distance; timer.reset(); LED_sleep = false; } // check button state if (digitalRead(BUTTON_PIN) == LOW) { stopdistance = distance; eeprom_write_word(&stopdistance_ee, stopdistance); increment = (startdistance - stopdistance)/NUM_LEDS; } if (!LED_sleep) { if (distance > startdistance) { for (i = 0; i < NUM_LEDS; i++) { leds_L[i] = leds_R[i] = CRGB::Black; } } else if (distance <= stopdistance) { for (i = 0; i < NUM_LEDS; i++) { leds_L[i] = leds_R[i] = CRGB::Red; } } else { for (i = 0; i < NUM_LEDS; i++) { if (distance > (stopdistance+increment*i)) { leds_L[i] = leds_R[i] = (i < AMBER_LEDS) ? CRGB::Orange : CRGB::Green; } else { leds_L[i] = leds_R[i] = CRGB::Black; } } } FastLED.show(); delay(50); } else { delay(SLEEP_POLLDELAY); } } ```

Anonymous user

2 years ago

Hello Jeboo, do you have a variation of your revised code that keeps the original all green LEDs lit until you get to a certain distance and then it changes to amber? You revision when I test it starts off with green and amber displayed straight away.

Anonymous user

3 years ago

If you add a push button on a digital pin (BUTTON_PIN) and ground, you can set the exact distance required, when the car is in the right position by pressing the button. The stop distance is saved in EEPROM, so power cycling the device will not change it. Of course, it needs change in the code, please, see the modified code below. I also added a timer, so that the LEDs would turn off after a configured period of time (LED_TIMEOUT), if the car is stopped (with a tolerance of DISTANCE_TOLERANCE). I cleaned up the code a bit too, so that defining NUM_LEDS is enough to change the number of LEDs, no need to add if-then-else sections to achieve that. ``` #include <FastLED.h> #include <QuickStats.h> #include <avr/eeprom.h> // not the default Eeprom.h, but the avr version !!! #include "Timer.h" QuickStats stats; Timer led_timer; #define NUM_LEDS 30 #define AMBER_LEDS 4 // number of amber LEDs when car is close to stop #define DISTANCE_TOLERANCE 3 // tolerance to determine if the car is stopped (centimeters) #define LED_TIMEOUT 120000 // in milliseconds // defining the pins #define BUTTON_PIN 6 #define LED_PIN 7 #define TRIG_PIN 9 #define ECHO_PIN 10 // defining variables CRGB leds[NUM_LEDS]; float duration; float durationarray[15]; int distance; int previous_distance; int stopdistance_ee EEMEM; int stopdistance; //parking position from sensor (CENTIMETERS) int startdistance=300; //distance from sensor to begin scan as car pulls in(CENTIMETERS) int increment=((startdistance-stopdistance)/NUM_LEDS); int incomingByte = 0; void setup() { stopdistance = eeprom_read_word (&stopdistance_ee); pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); Serial.begin(9600); } void loop() { for (int i=0;i<=14;i++) { // Clears the trigPin digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds durationarray[i] = pulseIn(ECHO_PIN, HIGH); distance= durationarray[i]*0.034/2; } duration = (stats.median(durationarray,15)); // Calculating the distance distance= duration*0.034/2; // Serial.print("stopdistance: "); Serial.println(stopdistance); // Serial.print("distance: "); Serial.println(distance); // Serial.print("previopus_distance: "); Serial.println(previous_distance); // Serial.print("led_timer: "); Serial.println(led_timer.read()); if (previous_distance-DISTANCE_TOLERANCE<distance && previous_distance+DISTANCE_TOLERANCE>distance) { if (led_timer.state() == STOPPED) { led_timer.start(); } } else { led_timer.stop(); previous_distance = distance; } if (digitalRead(BUTTON_PIN) == LOW) { stopdistance = distance; eeprom_write_word (&stopdistance_ee, stopdistance); } if (led_timer.read() > LED_TIMEOUT) { led_timer.pause(); for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Black; } } else if (distance>startdistance) { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Black; } } else if (distance<=stopdistance) { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Red; } } else { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB::Black; if (distance>stopdistance+increment*i) { if (i<AMBER_LEDS) { leds[i] = CRGB::Orange; } else { leds[i] = CRGB::Green; } } } } FastLED.show(); delay(50); } ```

Anonymous user

2 years ago

What Timer library are you using, i couldnt find any compatible ones.

Anonymous user

3 years ago

Any reason to not use the usb for the power? Thank you

Anonymous user

4 years ago

Hi, nice idea, but where can i get this Metal Blade "Princess...". Thanks René

Anonymous user

2 years ago

Amazon. About 10$ - 12$ US

hobbypaul

4 years ago

hello, i am newbe whit arduino, because this project is so good explained i want to try making this one because i have some parts to do this, only i have WS2812B RGB / 60 LED / meter and i changed this, #define NUM_LEDS 30 but i can't get the leds to work, must i do more ? I SEE ONE COMMENT LIKE THIS AND THE ANWER ¨^ modify that IF statement and add enough ELSE IF's for the number of LEDs you have , can someone help me plz

hobbypaul

2 years ago

I was a bit hopeless at first but after checking everything I learned something, everything works perfectly and I was able to solve it myself, thanks anyway for thinking along to find a solution

Anonymous user

2 years ago

[code] /* * Garage Parking Sensor - Published By Bob Torrence */ #include <FastLED.h> #include <QuickStats.h> QuickStats stats; //initialize an instance of this class // defining the pins #define LED_PIN 7 #define NUM_LEDS 30 const int trigPin = 9; const int echoPin = 10; // defining variables CRGB leds[NUM_LEDS]; float duration; float durationarray[30]; int distance; int stopdistance=115; //parking position from sensor (CENTIMETERS) int startdistance=400; //distance from sensor to begin scan as car pulls in(CENTIMETERS) int increment=((startdistance-stopdistance)/15); void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); Serial.begin(9600); // Starts the serial communication } void loop() { for (int i=0;i<=29;i++){ // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds durationarray[i] = pulseIn(echoPin, HIGH); distance= durationarray[i]*0.034/2; Serial.print(distance); Serial.print(" "); } duration = (stats.median(durationarray,30)); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); if (distance<stopdistance){ for (int i = 0; i <= 29; i++) { leds[i] = CRGB ( 255, 0, 0); FastLED.show(); } } else if (distance<stopdistance+increment){ for (int i = 1; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 0; i++) { leds[i] = CRGB ( 255, 255, 0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*2){ for (int i = 2; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 1; i++) { leds[i] = CRGB ( 255, 255, 0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*3){ for (int i = 3; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 2; i++) { leds[i] = CRGB ( 255, 255, 0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*4){ for (int i = 4; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 3; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*5){ for (int i = 5; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 4; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*6){ for (int i = 6; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 5; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*7){ for (int i = 7; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 6; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*8){ for (int i = 8; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 7; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*9){ for (int i = 9; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 8; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*10){ for (int i = 10; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 9; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*11){ for (int i = 11; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 10; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*12){ for (int i = 12; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 11; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*13){ for (int i = 13; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 12; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*14){ for (int i = 14; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 13; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*15){ for (int i = 15; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 14; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*16){ for (int i = 16; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 15; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*17){ for (int i = 17; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 16; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*18){ for (int i = 18; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 17; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*18){ for (int i = 18; i <= 298; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 17; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*19){ for (int i = 19; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 18; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*20){ for (int i = 20; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 19; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*21){ for (int i = 21; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 20; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*22){ for (int i = 22; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 21; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*23){ for (int i = 23; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 22; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*24){ for (int i = 24; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 23; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*25){ for (int i = 25; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 24; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*26){ for (int i = 26; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 25; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*27){ for (int i = 27; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 26; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*28){ for (int i = 28; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 27; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } else if (distance<stopdistance+increment*29){ for (int i = 29; i <= 29; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 28; i++) { leds[i] = CRGB ( 0, 255,0); } FastLED.show(); delay(50); } } [/code]

Anonymous user

2 years ago

I posted the code for a 30 light LED. hope it helps

Anonymous user

4 years ago

I'm trying to make this one. I'm using 2 strips with 30 LEDs each, and I've modified the line #define NUM_LEDS 15 to #define NUM_LEDS 30 but even with this mod there are only 15 LEDs working in each strip. Can you please advise what might be needed to light up the 30 LEDs in each side? Thanks! Eduardo

hobbypaul

2 years ago

hello Eduardo, do you find the solution for your problem? i have the same problem here, can you help me plz?

Anonymous user

2 years ago

There is an IF statement in the code that walks down through the LEDs. If you change the number of LEDs then you need to modify that IF statement and add enough ELSE IF's for the number of LEDs you have.

Anonymous user

4 years ago

Hi can some body send me pic how connect all i have problem. I want Just use it all Time on at Time dorrs is opening. When i did it i burn 2 aruinos so please send me how connect all thanks

Anonymous user

4 years ago

Hello, What power supply will be good for this project? The 5V 5A will be good enough?

procyon78

2 years ago

Correct, a 5A power supply is more than enough. Each LED can draw 20mA at maximum light intensity for each colour, so your maximum rating is 20mA x 3 colours x 30 LEDs = 1.8 Amps

Anonymous user

4 years ago

It would be nice to attach a bit more photos. Especially step one and two. I am kinda lost on what goes where and how to solder leads on the LED's (where I am supposed to solder the leads).

Bcjams

2 years ago

Thanks for the feedback. Unfortunately I do not have any components to go back and take photos of at the present time. You can reference the wiring diagram, however, as the LED strip is shown in great detail and looks just like the actual strip.

christopher_haresnape

4 years ago

Beautiful.

Anonymous user

5 years ago

Where can I get these 2.5 and 3mm screws that are needed? I don’t see a link in the supplies section. Thanks.

Anonymous user

2 years ago

But how long do they need to be? I am in US. I see M3 screws, is that what I need?

Bcjams

2 years ago

I get all my fasteners from our local Fastenal, but you can also obtain at McMaster-Carr

Anonymous user

2 years ago

Depends where you are. In the UK, I get most of my machine screws from RS (Components). Good choice of materials from nylon to 304 stainless. If you need a thread to be cut, try trilobar or thread cutting screws, or self-tapping screws. For really small screws, try model-making supplies.

Anonymous user

2 years ago

Author refers to 2.5-mm screws. Half sizes can be hard to find sometimes. I would use 3-mm as these are commonly used. Can't help you with length as I can't see the fixing holes. If I don't know what length is best for my projects, or it's a non-standard length, I simply buy longer screws and cut to length. I'm guessing, but as this is a printed box, it is not going to have threads cut so you might need self-tapping screws which you can't cut (hardened steel). Commercial enclosures will either use blank holes for use with self-tapping screws or the will have threaded inserts, usually brass, that press into a blank hole and give you a machine thread. Looking at an Arduino here, 3-mm would be fine. You can always open up the holes with a reamer or carefully with a drill bit. With projects like this you just have to adapt to what's available. There are always other solutions like double sided tape and PCB supports. Don't forget machine screws are measured on the overall length if countersunk, or on the threaded length if pan-head or cheese-head

Anonymous user

5 years ago

Hello, I will be making this project, I just need to know, how many amps does the transformer use for the 120VAC to 5v DC?

Anonymous user

2 years ago

Which transformer? The author would be best place to answer your question, but it looks from the schematic that the circuit uses a plugtop (wallwart?) or pluggable power supply. These can be unregulated, regulated or Switched Mode. The schematic shows 5-V DC being fed into the Vin on the Nano and also feeding the 30 LEDs. Introducing a diode (1N4148) drops the voltage further. The 1N4148 is a signal diode and really needs to be beefier like a 1N4001, or better, a Schottky The Nano 5-V regulator fed from Vin really needs more than 5-V to work properly, more like 9-V. As an estimate, take 30 x 20-mA for the LEDs, add on the Nano consumption from the datasheet, same for the sensor. Add on a 50% overhead for safety. This will be the current at 5-V DC. At a guess, 1-Amp at 5-V would be adequate. If I were doing this, I might start with a 9-V DC power supply, supply this to Vin on the Nano and use a separate 5-V regulator for everything else. Don't put voltage into the pin marked 5V on the Nano - this is an output from the regulator. If you have access to a multi-meter or a bench power supply, you can see the actual current being used.

Anonymous user

5 years ago

This is really cool. What is everyone doing for power? I dont want to run a wire all the way to the garage door but also dont want this thing on all the time the car is parked

Anonymous user

5 years ago

Hello very good Idea , but i have one problem with the function , i have installed the newest Arduino IDE , with FastLED and Quickstats , the Problem is she doesn't work... Can you tell me which arduino IDE , FastLED and Quickstats version you use. thank you best regards Alex

Anonymous user

2 years ago

I found the Error , one LED Stripe was in to the false direction. best regards alex

chami15

5 years ago

Hi! I'm doing the project but I have some problems, one is about the code, it says that and I would like to know how to solve it. Thx so much, your project it's amazing! In file included from /Users/macbookpro/Documents/Arduino/libraries/FastLED/noise.h:4:0, from /Users/macbookpro/Desktop//Proyecto_v1_1/Proyecto_v1_1.ino:1: /Users/macbookpro/Documents/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.002 # pragma message "FastLED version 3.003.002"

Anonymous user

5 years ago

I also made one with some tricks, but it works now. I still have to hang it. That is the last job.

Anonymous user

5 years ago

Hi I am gald to see your design, some questions about the arudino. 1.I just find out the FastLED data in the arudino library, and I saw the information in comments. So I find the file for QuickStats and make it zips file and add it into the library. Once I inserted the QuickStats files and that showed some .h files, and the FastLED.h change to red color. Could you have some idea what's going on? Any idea how to deal with these problem? I really appreaciate that. With regards.

chami15

2 years ago

I have the same problem have you solved it? Thx so much

Anonymous user

5 years ago

I just wanted to let you know that I am also working on this project. I got my parts yesterday and had it up and running in about an hour. I bought a 60 led strip instead of the 30 led strip you used, so I had to modify the code a little, and I change a few things while I was in there as well. Overall, this is coming together nicely. I plan on wiring the power up to mine a little different as well, just to satisfy another condition of the door I need to monitor. I am hoping to also use a couple of buttons to set start/stop distance as well, as another poster had mentioned. I will keep you updated on how all that goes.

Anonymous user

2 years ago

Good luck will be watching your progress.

Anonymous user

2 years ago

I have mostly completed the project. I ended up not putting in a range pot or anything, mainly because I can't think of needing to adjust it that often, and there is so little room in the enclosure. Since our van barely fits in our garage, I mounted a switch on the door rail to sense when the door is fully open. I ran the power to the sensor through this, so when the door is open, the circuit will power up and the leds will light up to let us know that it is safe to back the van out, or pull the van in. The only issue with this is if we leave the garage door open, then the leds will remain. I need to put some some code in to detect a "sleep" period after the power has been on for a certain amount of time.

chathuraindrejith22

5 years ago

Your project is super. 'FastLED' is only available in libraries and I installed it but 'QuickStats' ,'startdistance' and 'stopdistance' is not available what's the solution for it please reply me soon

Anonymous user

2 years ago

I found Quickstats through a Google search. 'startdistance' and 'stopdistance' are program variables that are define in the top of the program. You don't need to do anything with them other than set your distances.

Anonymous user

5 years ago

Hi Mate, would you be willing to share the model files? I'd like to make some adjustments (my components are a little bigger than expected) Please and thank you.

Anonymous user

2 years ago

Make sure that your units are set to metric when you add the objects to your software. I had the same issue when I tried to pull them in as "inches".

Anonymous user

5 years ago

Bcjams: Have finished project and am would like to include a video of my setup in action. How can I post the video and maybe you can take a look at it and give me your opinion as to what adjustments I might have to make. Thanks again

Anonymous user

6 years ago

Is there a way to setup a pot for adjustment and possibly a button to record the current cars position?

Bcjams

2 years ago

To add pots and switches, all you would need to do is connect them to some unused pins and use these to set the ‘startdistance’ and ‘stopdistance’. You can google this to find examples of how to make variables set using pots and switches. Sorry, but I don’t currently have the time to write some example code for this. Packaging these might be a bit tricky, as there is not much room inside the control box to add more wiring. If you have access to create your own Cad models, a suggestion would be to add a spacer ring under the top cover (where ultrasonic sensor is mounted).

Anonymous user

6 years ago

Bcjams: Having trouble with my leds just turning on red when object is close to sensor. I just want to be sure I understand the part of the code that defines the number of leds. Is the number defined the number of leds on each side or a total number of leds in the project? Thanks

Bcjams

2 years ago

The way the code works is the lED’s are mirrored left side and right side , so whatever happens to right will be same on left. The Led’s are numbered 0 through 14 (15 leds in total, with the 0 position closest to control box. As you read through code you will see at maximum range all LED’s are green. As an object approaches the ‘stopdistance’ lights at outer ends turn off. As object moves even closer, anybremaing lights will begin turning yellow and continue turning off sequentially until only one remains lit on either side of center. As soon as object reaches stopdistance all lights turn on red. If objects continue to get closer all red lights remain on. You can change program any way you would like as you because familiar with programming. One thing you could do is have all lights flash red if object continues to move past the stop distance. Anything is possible. You would do no harm by experimenting which is half the fun of the project.

Anonymous user

6 years ago

Bcjams: I have all the components installed (not in the case) and doing test on the entire system. I get a constant stream of red leds, so I thought maybe I had some problem with the sensor settings so I changed the code to: int stopdistance=75; //parking position from sensor (CENTIMETERS) int startdistance=150; //distance from sensor to begin scan as car pulls in(CENTIMETERS) . This doesn't work either. Any suggestion as to what changes to try? Thanks

Anonymous user

2 years ago

Thanks Phil-S, I appreciate all of your input it has been very helpful. I am on a track to get this project completed. It may take me longer since I don’t have all the knowledge, but I am a fast learner and persistent. I enjoy the challenge of a project of this caliber and will celebrate in its completion.  Thanks again for your input.  

Anonymous user

2 years ago

Not seeing anything on serial monitor. I will check wiring again and sensor. Just a quick question about the diode, in your schematic it appears that the thin black line points toward the connection to the Arduino from the power source, is that correct? Thanks

Anonymous user

2 years ago

Have changed the sensor and this is what I see on the serial monitor: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distance: 0 What would you suggest I check at this point? Thanks

Anonymous user

2 years ago

I did get it to work after changing the sensor. I am having trouble now after assembling all the parts. There is so little room with all the wires even after installing the capacitor outside the box. I have been using solid wire, I am going to redo the wiring with stranded wire and see if I can get everything into the case and have it to function after closing the case. Thanks for your help and encouragement. Danny PS I will keep you posted.

Anonymous user

2 years ago

Ok now I have added the 5v power and connected the USB to the serial port and this is what I see: 31 30 30 30 30 30 31 30 31 31 31 30 31 31 30 Distance: 30 31 30 31 30 31 31 31 31 31 31 31 31 31 31 31 Distance: 31 31 30 31 30 30 30 30 30 31 30 30 31 31 31 31 Distance: 30 30 31 30 31 30 30 30 30 30 30 30 30 30 30 30 Distance: 30 31 31 30 30 30 30 30 30 30 30 31 30 31 31 30 Distance: 30 30 30 30 31 30 30 30 30 30 30 30 30 30 31 31 Distance: 30 30 31 30 30 30 30 30 30 31 30 30 31 31 31 31 Distance: 30 30 31 30 31 31 31 30 31 31 30 31 31 31 31 30 Distance: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 Distance: 31 30 30 30 30 31 31 30 30 30 31 30 30 31 30 31 Distance: 30 31 31 30 31 31 31 31 31 31 30 30 30 30 31 30 Distance: 31 32 31 31 31 31 32 31 32 31 32 31 32 32 32 32 Distance: 32 2225 2225 2225 2225 37 37 37 37 37 37 37 36 36 36 36 Distance: 37 I don't see any leds turning on or off.????

Anonymous user

2 years ago

For really fine wire, try any of the following. Ethernet cable like CAT5e has 8 cores of solid insulated wire. Wire-wrapping wire is also solid, but very fine. Alarm cable, stranded, very flexible, get 8 cores of coloured wires. On the subject of components, it usually pays to start with branded items from people like Adafruit, Sparkfun etc., or mainline distributors like RS and Farnell. Amazon and eBay are awash with clones and cheap copies. Some work and some don't. Plus you won't get any support. Elegoo do very good versions of Uno, Nano and Mega at a fraction of Arduino prices, but Arduino does rely on product sales to maintain the project as a whole.

Anonymous user

2 years ago

The diode is in the positive supply line to the Nano to protect against reverse connection. The 1N4148 is a glass bodied diode and the black band denotes the cathode and in this application, the cathode points towards the equipment being powered, the Nano. Personally, I might use a diode with a higher current rating like a 1N4001. These are black plastic bodied with a silver or white band. You might need to add some lines of Serial.print in the loop and setup to see where it's stalling. Make sure your comms baud rates are the same in the monitor and in the code. 9600 is a good choice. Also, line end should be the default "New line"

Anonymous user

2 years ago

Is this your first project with ultrasonics? If it is, I would take a step back and try a simple project with with just the sensor (try the Arduino Playground) or a tutorial (must be loads of them online - any robotics project will do) just to get your confidence back, then work up to the full LED thing. If the code is good and tested, then it most likely is going to be in the wiring. Have you changed any pins or settings/variables in the code. It looks as though changing the power supply arrangements has done something. What you have omitted to say is how are you testing the setup. I would stop and check everything, especially power, before something starts smoking. It's a reasonably complex project and quite easy to get something wrong. All those LEDs lit up at once could seriously pull power down.

Bcjams

2 years ago

Danny, with the output reading 30 (cm) all red LEDs will be on, as you had changed your stop distance to 75 per a previous message post. Is there anything partially blocking your ultrasonic? They have a 15 degree window I believe, so if it is sitting on a bench it may be getting a reflection. Try holding the sensor away from objects to see if value changes. It could be a faulty sensor. I would recommend you try reloading the original code (without edit) to see what happens. Once you get it working you can edit the start/stop distances. The code is well tested (I have built two of these with no issues).

Bcjams

2 years ago

Great to hear that you have it working! You are on track with going for the stranded wire. I use silicone 22 AWG wire which is sufficient for the current and is. very flexible. It is a tight package to wire up, but very doable if you are careful and patient. Also plan ahead with where you want to splice your wiring to branch off to the various points of connection. I created the primary splices and tucked them under the Arduino.

Bcjams

2 years ago

With Arduino connected to USB, open up a serial monitor window. The distance will be displayed. If it outputs only 0’s, that would indicate a wiring or sensor issue. Otherwise it will give you distance in cm.

Yahooman

6 years ago

Great project. How did you calculate capacitor and resistor? Regards Mike

sithlordhood

6 years ago

Hi, I just noticed a slight (possible?) error in the code, whereby 2 of the green LEDs turn off at the same time as the car approaches, maybe this is how you wannted it? In this part of the code: if (distance<stopdistance+increment*9){ for (int i = 9; i <= 14; i++) { leds[i] = CRGB ( 0, 0, 0); } for (int i = 0; i <= 9; i++) { leds[i] = CRGB ( 0, 255,0); To make the LEDs turn off one by one as the car approaches, change: for (int i = 0; i <= 9; i++) { to: for (int i = 0; i <= 8; i++) { Hope this helps. Also i am interested in having the whole thing powered up all the time as i want to put the LED strips on the wall outside on the driveway, not in a garage. Therefore i need the project powered all the time, to stop the LEDs being Green all the time i have changed the final line so that if the car is greater than say 100cm away, no LEDs will be lit: else if (distance>=stopdistance+increment*14){ for (int i = 0; i <= 14; i++) { // leds[i] = CRGB ( 0, 255,0); - original code so that green is always shown leds[i] = CRGB ( 0, 0, 0); //new code so that all LEDs are off } FastLED.show(); delay(50); But how do i easily add some kind of timer to say if the LEDs have been in a steady state (ie the distance not changing) for greater than say 2 minutes, the LEDs will shut off. Also i want it so that if someone gets in the car and starts to back out or go forward the LEDs come back on, any ideas? Thanks!

Teling2

2 years ago

I used a photoresistor in a straw aimed at the lights of the garage door opener. The lights turn ON for a set time after opening so I have the LED strip disabled if no lights are detected.

Bcjams

2 years ago

Thanks for the catch! I updated the code accordingly. If you have the LED's outside, I would recommend you make sure the RGB strip is waterproof. The ones I used are not waterproof, but they do offer them. As far as how to turn off after 2 minutes, that should be achievable. You would need to setup a counter in the loop that would look for state of change. Anytime change is seen, counter would reset to zero. If counter reaches 2 minutes, the lights turn off. If someone gets in the car again, lights would come back on because it would see change of state (distance) once again. The only problem I see with this, however, is that the HC-SR04 appears to be sensitive to random signals (which is why I used a Median Value calculation to throw out random signals), so you may end up with lights turning on and off throughout the day. If you keep the calculation for change of state lenient (maybe with about 10cm?), it might have a good chance of success. Good Luck!

sithlordhood

2 years ago

Thanks, I have noticed that the reading from the sensor varies quite a bit when just pointing at a wall with no movement inbetween, so as you say i dont think ill get a few minutes whereby the reading remains steady enough for a couter to reach 2 mins. I am thinking of using a standard PIR sensor which would detect heat/motion from a car, then wire the +5v supply to the LEDs from this.

Anonymous user

6 years ago

Hello again Bcjams, I am trying to assemble all of the electronics into the case, but am having trouble with the capacitor. I ordered one from Newark but it has not come yet, all of the other parts came ok. The info on the capacitor from Newark is: ECA-1EM102. - Electrolytic Capacitor, 1000 µF, 25 V, M Series, ± 20%, Radial Leaded, 10 mm. So I took this information to Mouser ( I am close enough to do a will call from them) I used the same information from Newark, but the capacitor is a bit too long to fit into the space inside the case. Did you use a different capacitor? The one you show in the picture looks different from the one I have from Mouser. Also if I powered the Arduino from the USB connector and wired the LEDs directly from the 5v on the Arduino, would I still need the capacito? Thanks in advance for your help. Danny

Bcjams

2 years ago

Phil-S, thanks for your input. I used the 1000uF based on protecting the RGB strip, not necessarily the Arduino. This was gathered as recommendations I had seen for using RGB strips. I agree with you that it may not be necessary, but I would rather be on the safe side. After reviewing this again, I do see that recommendations were to use capacitor values between 100uF and 1000uF. The 100uF will be much smaller in size, so that would be another good option.

Bcjams

2 years ago

Should work fine. Let me know how your build goes!

Bcjams

2 years ago

The capacitor I used was a 16V rating, which is smaller in size than the 25V. I had gotten this through a capacitor assortment kit I had purchased on Alibaba. The capacitor is there to prevent potential spikes from power supply. The exact value is not that critical, so I would find one as close to 1000uF as possible that will fit down inside case. You can't connect LED's directly to Arduino, as the LED's pull more current than the Arduino voltage regulator can supply. If you cant find right size capacitor, another option would be to wire the capacitor you have on external power leads coming into the unit.

Anonymous user

2 years ago

I picked up a 100uF capacitor from Mouser MFG P/N: ECA-1EHG101I, so do you think this will be sufficient to use (it is much smaller and will fit in case)? Thanks

Anonymous user

2 years ago

Not my project, but capacitor is not normally critical unless calculated necessary. A minimum on anything digital might be 10uF electrolytic with 0.1uF ceramic in parallel. You can safely add 0.1uF across the power lines of any IC, as close as possible. A 470uF would probably work OK or two 470uF in parallel to give ~ 1000uF Arduino Uno and Mega have two 47uF already on the board, but Nano has nothing that large, 6u7F on my schematic, so anything larger would help

Anonymous user

2 years ago

Danny - you are being too cautious. Try it and see. Manufacturers quite often over-specify things to be on the safe side. Put in as much capacitance as will fit, but it will probably be overkill. Too much though can cause problems of large inrush currents when you power up. Go for 100uF. When you get into Farad sized capacitors, then that's big.

Anonymous user

6 years ago

Great project! I just got my parts back from the 3D printer and I have a question about the part labeled HoldDown. I assume it must go on the Arduino, but can't quite figure out where. Do you have an explanation or maybe some photos to show how they fit together? Thanks

Bcjams

2 years ago

Danny, I have uploaded the build photos to the key project steps.

Bcjams

2 years ago

Danny, I apologize. I just realized I had forgotten to upload some of the build photos. I don’t have access to my computer right now, but will upload these photos in a few hours. In the meantime, you can go to Thingiverse website and search “bcjams garage” and the project will show up there with photos of the build.

Anonymous user

2 years ago

Thanks for the photos they really help.

Anonymous user

6 years ago

Very nice project. Thx a lot.

Anonymous user

6 years ago

Nice project, but how can i adjust the distance thanks

Bcjams

2 years ago

You will need to modify the parameters in Lines 18 and 19. See the comments on those two lines for definition/explanation.

Anonymous user

6 years ago

I'm getting this error when trying to compile the sketch: /tmp/037995901/sketch_apr21b/sketch_apr21b.ino:5:24: fatal error: QuickStats.h: No such file or directory compilation terminated. exit status 1 Am I missing something?

Anonymous user

2 years ago

Thanks, I've figured it out. I'm just starting out with Arduino, this will be my first project, so I've got some learning to do on all this compiling. I've already printed the parts, that was the easy stuff for me. I bought the Arduino to put a bootloader on one of my printers, and wouldn't you know it, here I am. Another hobby. Lol... Thanks again.

Bcjams

2 years ago

You need to load in the ‘QuickStats’ library to your IDE before compiling.

sithlordhood

6 years ago

Great project, will be looking to use some of this in my build of a parking light on the garage door when parking in the driveway. P.S. The diode in the wiring diagram is round the wrong way

Bcjams

2 years ago

Ah, good catch! I will update the wiring diagram when I get back to my computer! Thank you!

Anonymous user

6 years ago

Awesome project my friend :) Quick question how can i modify this using a 3 car garage?? ...What i am thinking is one Arduino (the brain) and 3 sonic sensors wired in parallel do you think that will work ?? Meaning that if one of the sensors has a car moving and obviously in the garage only one car can enter at a time than the whole strip will light up accordingly.??? But that brings me to thinking that lets say that the parallel sensor thing works than what happens if there are other cars already parked ??? how can i modify the code than that 3 sonic sensors act independently ?? Oh another question ...i have all the other parts but an Arduino Uno instead of your Nano R3 will it work with Uno?? Thank you again

Bcjams

2 years ago

It would be a challenge to get this particular design modified to incorporate three garage doors. Just trying to wire three sensors within the case would not be feasible due to case size. Also, it would be challenging (but not impossible) to determine status of the other two vehicles (whether or not they are present and already parked. If it were me, I would just have three individual light bar assemblies, one for each door. I think my total cost per unit was less than $8.

Anonymous user

6 years ago

I like the idea of this project very much. I have used ping pong balls, mirrors, and other methods for parking inside my garage. However, this is the best I have ever seen. I have already found the clear half round lens mater but have not sourced the track material the LED strip lights sit in that holds the lens. I see that you have included files to print them. Is that what you did, or did you purchase them. If you did purchase the track pieces can you tell me what the source is. I don't have a 3D printer. I may be able to have a friend print the other pieces but not the tracks. Thanks.

Bcjams

2 years ago

I printed the tracks on my 3d printer. I designed it to fit on most printers, as most have 200x200mm or larger build platforms.

Anonymous user

6 years ago

Great job! I made a very similar project, all the way down to the half rod lens haha, but I like your light style better with it split down the middle. If you use an internet connected micro, you can also add some functionality such as warning you if the garage is left open, or someone is in your space. Thanks for sharing

Anonymous user

6 years ago

Looks like a good idea and well implemented. What did catch my eye was the threat of violators being "toad", or was that meant to be "frogged"? A well tried "old tech" method used to be to suspend a ping pong ball from the ceiling in such a position that it just touched the windscreen when the vehicle was at the correct distance.

Anonymous user

6 years ago

Love the sign.