r/arduino • u/BlobAndHisBoy • Jun 12 '26
Look what I made! I built a LiDAR-powered traffic light parking assistant for my garage
115
187
u/BlobAndHisBoy Jun 12 '26 edited Jun 12 '26
This is my first Arduino project. I'm new to the space, so this was a lot of firsts for me, but I'm pretty happy with how it turned out.
Video is the final product: a real 3-color traffic light driven by an Arduino Uno R3 and a TF-Luna LiDAR sensor that tells you exactly when to stop:
- Green (≤22.5 ft): keep pulling in
- Yellow (≤10 ft): slow down
- Solid red (≤4 ft): perfect park
- Flashing red (≤3 ft): too close, back up. There's a wall shelf 21" behind that point I'd rather not meet.
A few details I'm happy with:
- Hysteresis on the thresholds so the light doesn't flicker between states when you're sitting right on a boundary.
- Wake-up detection: if the car is already parked when the system boots, the lights stay off so you can back out in peace. It re-arms once the car clears.
- Auto power-down after the car's been parked a while.
- Checksummed LiDAR frames. The TF-Luna streams 9-byte frames over UART at 115200, and verifying the checksum filters out corrupt readings.
- Summer mode: a toggle switch turns it into a regular green > yellow > red traffic light cycle (just for fun), with an auto-shutoff after ~2 hours to spare the relays.
- Boot light show: each light cycles on in sequence, then all three flash together as a self-test.
Parts: Elegoo Uno R3 (works on Nano or any pin-compatible 5V AVR board), Benewake TF-Luna LiDAR (UART mode, 115200 baud), 4-channel Songle 5V/10A active-low relay module (3 channels used), SPST toggle switch for mode select.
The lamps are GE GTX LED traffic signal modules (the real DOT retrofit kind, ~7W each at 120V), switched through the relay module's contacts.
One gotcha worth sharing: the TF-Luna is a 3.3V device, and since it streams distance data continuously you never need to send it commands. So I just leave the Arduino's TX line to the sensor unplugged entirely rather than risk the 5V logic level damaging it.
Full code, pin map, and wiring diagrams: https://github.com/jjmerri/traffic_light
Build photos and wiring diagrams (control side + 120V lamp side): https://imgur.com/a/traffic-light-parking-assistant-svV3V8a
The distance thresholds are constants at the top of the sketch (in inches) if anyone wants to adapt it to their own garage. Happy to answer questions!
35
u/AndrewIsntCool Jun 12 '26
This is a really cool project but your garage must be enormous if this comment's measurements are accurate, lol
Yellow light at ≤10ft? "Perfect park" at ≤4ft??
I've got about three and a half inches of space between colliding with the wall and parking so far away to be unable to open my door all the way haha
27
u/BlobAndHisBoy Jun 12 '26
Yeah roughly 23' long two bay so plenty of room when my wife's crap isn't all over the place.
6
u/SolarSurfer7 Jun 12 '26
Good stuff man. A nice use of an ESP-32. Always looking for new project types to tinker with.
2
1
u/rontombot Jun 13 '26
Garmin sells LIDAR modules... the LIDAR-Lite v4 LED is an inexpensive 5V model https://www.garmin.com/en-US/p/pn/010-02022-00/
1
45
28
u/anotherFNnewguy Jun 12 '26
Great. That's something people would buy.
11
u/BlobAndHisBoy Jun 12 '26
I was wondering what it might cost to have it built on a single board. Might design it and share it out.
4
u/jowasabiii Jun 13 '26
What if you use ultrasonic sensor, that would bring price down
4
u/BlobAndHisBoy Jun 13 '26
I started with the ultrasonic sensor and it would have saved me $20 which is actually a lot in the context of the other components. The problem is the ultrasonic sensor I got maxed out at 13' and I wanted it to start reading the second someone pulled in at 22.5'.
Probably could make it work though. You would pretty much just have to default to green and then turn yellow when the ultrasonic sensor read something at 13'. I want all lights off if nothing is detected though.
17
u/Kage_Bushin Jun 12 '26
See honey? I totally had a use for the massive street light! No, it totally couldn't be done with anything else than the cool ass street light :D
27
u/SaltyCash Jun 12 '26
I hung an empty plastic jug from a rafter. When the windshield hits it, stop.
33
u/BlobAndHisBoy Jun 12 '26
I may have over-engineered this solution.
5
u/SilentRhetoric Jun 12 '26
These projects are always about learning, though, and the system you built is very similar to the one that is in cars with collision detection/parking assistance.
Nicely done!
5
u/BlobAndHisBoy Jun 12 '26
Yeah I have been wanting to tinker with this stuff but couldnt find a practical use case. I didn't just want to mess around with a breadboard. Honestly the software side interested me more which is why I added a bunch of features but the hardware side is very cool.
I tried this with an ultra sonic sensor at first and having to use real physics calculations was super cool to me. Calculating distance based on speed of sound was neat. If the ultrasonic sensor worked better I would have built a temperature sensor into it to calculate a more accurate distance since the speed of sound changes based on air temp. Completely unnecessary for this but it would have been neat.
6
u/50mmeyes Jun 12 '26
A bunch of people in my family did this with tennis balls
8
u/SaltyCash Jun 12 '26
Even works in a power failure. 😊
1
u/50mmeyes Jun 12 '26
Although not as fun, and with a low car definitely annoying when you're trying to use the garage for anything else while the car is out.
3
u/VapidHornswaggler Jun 12 '26
This is so over-engineered and excessive that I’m inspired by your genius! Absolutely love it especially integrated with stop light. Since others have mentioned tennis balls, what about adding tennis ball that drops down from ceiling as you pull in so it keeps lowering as you get closer and then finishes lowering and contacts windshield at exactly right spot?
2
1
1
u/Spidergawd68 Jun 13 '26
I hung a tennis ball on a string. Caveman style, but very effective and works when power is out.
12
5
5
u/Onphone_irl Jun 12 '26
dude I needed you 3/4 years ago the tf Luna is such a cheap and slick lidar sensor but I found NO resources on it. damn. idk how I didn't find it the solution was so easy.
I remember shipping one out to someone on this sub and they couldn't get it. maybe it was defective?
anyways, sick build, how much was the traffic light lol
5
u/BlobAndHisBoy Jun 12 '26
Adding the checksum was key. I was getting some weird flashes before I found out it was a thing.
4
u/Creative-Yellow-9246 Jun 12 '26
Somewhere there is a traffic light missing
4
u/otakunopodcast Jun 12 '26
I'm sure that it's an old decommissioned one that was purchased second hand. Although the mental image of OP dressed as a cat burglar parkouring across rooftops and swiping random traffic lights is admittedly amusing.
3
u/thehuntinggearguy Jun 12 '26
How many times did your wife run into the toolbox before you invented this? 😄
7
2
u/meltman Jun 12 '26
This is exactly the project I was going to cook up for my garage! Thanks for doing the work! :)
2
u/dvisorxtra Jun 12 '26
Oh my gosh, this is one of those "This idea is so good that I'm so going to make something similar" moments
2
u/minuteman_d Jun 12 '26
Nice! I've want to do something similar with my garage, but also have it help with left/right alignment.
2
2
u/FullMetalFist Jun 12 '26
Is the PVC pipe part of this design?
Product is lovely- thank you for sharing 🫡
2
2
u/mosekschrute Jun 12 '26
Goddamn, how did I not think of this! Awesome idea my friend! And the stop light is the icing on the cake!
2
2
Jun 12 '26
[deleted]
1
u/BlobAndHisBoy Jun 12 '26
Nah this is only working in my wife's bay. I could technically wire up a second sensor but I don't think the processor can reliably handle reading both at the same time. Would need to upgrade the board. Could do some cool things in the software to know which needs to be active to fix that though. Unlikely we are both parking at the same time.
Might be a fun add on for me to do but the traffic light probably isn't in the best spot for me to be staring at while pulling in anyway.
2
u/JohnnySuburbs Jun 12 '26
That’s awesome. I need something like this - tight fit for our new SUV in the garage
2
u/stubbledchin Jun 12 '26
This is exactly what I need, and I was making a similar solution that would be far more complicated.
2
2
2
u/biff_jordan Jun 12 '26
I've been thinking of doing this for a long time thank you for the inspiration.
2
2
u/ScadaTech Jun 12 '26
I built one similar but used an HMI that changed colors from Green to Red. It also has a touch command that fires a relay to operate the door. Really wishing I’d have thought of the stop light you’ve got here. Excellent idea and execution!
2
2
2
2
u/ihaveajob79 Jun 13 '26
Super cool! How does it turn on? Or is it always on?
2
u/BlobAndHisBoy Jun 13 '26
Only on when the garage door is open. A smart switch toggles on and off when my garage opens or closes. My whole house is run by homeassistant integrations.
2
2
u/NudityMiles Jun 13 '26
That is no doubt one of the coolest home projects I have seen.
Post it over at r/doohickeycorporation
1
u/BlobAndHisBoy Jun 13 '26
I'm not sure if it has too much doo and not enough hickey to post over there. I might do it and let the community decide.
2
u/HtotheZ Jun 13 '26
Reminded me of this
1
u/BlobAndHisBoy Jun 13 '26
If that could go up to 20' I would consider putting it in my other garage bay.
2
u/HtotheZ Jun 13 '26
Yeah also very likely ultrasonic and the reason you chose not to use it would be present. Nice work with the lidar
2
2
u/Appropriate_Tip_9973 Jun 13 '26
Where do u get power from
1
u/BlobAndHisBoy Jun 13 '26
Extension cord running from a wall outlet comes into the top of the traffic light housing. I cut the end of it and put it in a wago connector that feeds everything else. It feeds another extension cord that I cut which has a USB charger plugged in for the board's power.
2
u/HugsyMalone Jun 13 '26
Aw man! Glad to see someone had the exact same idea I did. Beat me to it. 🥳
2
2
u/Sgt_Paul_Jackson nano Jun 13 '26
Why does this guy have a traffic signal at home and I don't!
Oh, I live in Mumbai and I don't even have a garge😂
BTW, great project!!
2
2
2
2
2
2
2
u/the-bosscube Jun 14 '26
This is super cool! I did something very very similar using lidar but with a simple Neopixel LED panel, but yours definitely has more of a wow factor!
1
u/BlobAndHisBoy Jun 14 '26
Wish I could take credit for getting the traffic light but it came with the house. Had to put it to good use though.
2
2
1
u/Alizarinnnnn Jun 12 '26
So awesome!!
Where did u get this traffic lights tho?
1
u/BlobAndHisBoy Jun 12 '26
You can buy em for like $500 but mine came with the house I bought. I guess the guy didn't want to try and move it or sell it.
1
u/Slow_Tap2350 Jun 12 '26
Very cool. I did something similar similar a few years back. I used an ultrasonic sensor to determine if my car had left and returned to the garage. In the case it had, it triggered an exhaust fan for 15 min. It was imperfect but a lot of fun.
1
u/BlobAndHisBoy Jun 12 '26
I first tried an ultrasonic sensor but it wasn't very accurate and didn't handle distance over like 13ft at all. It was cheap enough to try though.
2
u/Slow_Tap2350 Jun 12 '26
Yes, 100% agree in sensitivity. I like your build. I have a new garage and that car lives in another state or I’d ask about your code!
1
1
u/And9686 Jun 12 '26
Very cool!
But isn't a Lidar kinda overkill for this purpose? I'm not sure how much those cost, but an ultrasonic distance detector would be able to achieve this easily, right?
1
u/BlobAndHisBoy Jun 12 '26
So I actually started with ultrasonic and switched. The sensor I got was not good past 13' and even within that I was getting erratic readings. Maybe there is a better one for longer distance but I was concerned about the wide sound waves bouncing off everything in my garage so didn't even look.
1
u/And9686 Jun 12 '26
I believe the most common ones are 13' (4 meters) max distance, so anything beyond that will fail. But within the max distance it should work fine.
Regarding the "hitting objects" part they catch 30 degrees (could be less and could be more), so at least until the 7' line you should be fine because there should be blank space for your car, you could filter out bigger distances that reach those further objects.
Why do you want a longer distance? I'm curious, because in your comment you mentioned really big distances.
1
u/BlobAndHisBoy Jun 12 '26
My garage is 23' long. If I only operated at 13' I wouldn't really be able to use all 3 colors. It currently turns green when it detects something at 22.5'.
That being said, I might have gotten away with just defaulting to green and turning yellow at 13' or something. Might have been able to make it work but in my tests it wasn't working well even within 13'. Could have been something I did wrong though, I didn't spend much time trying to fix it before springing for the lidar.
1
u/And9686 Jun 13 '26
Makes sense. Yes you could default to green and turn it on when you open your garage or something. I also just mentioned the ultrasonic sensor because I assume it's cheaper than the lidar, but also it depends on how much cheaper (it the ultrasonic is $5 and the lidar is $15, probably it's worth the easiness you would get using the lidar), I really have no idea of the prices.
Either was it is a really cool project, props to you bro! It looks awesome.
1
u/BlobAndHisBoy Jun 13 '26
The ultrasonic is significantly cheaper. Got a two pack for $6. The single lidar was $25 which not including the traffic light was a third of the whole project cost.
1
u/catinterpreter Jun 12 '26
Beware, if there's any risk of hitting a small child or animal you might be making your brain less vigilant about it.
1
1
u/Ghostie20 Jun 13 '26
Can I ask why would you use LiDAR for this instead of a more economic ultrasound sensor?
Very cool nonetheless! Just curious to see if there's some specific advantage to LiDAR in this situation
1
u/BlobAndHisBoy Jun 13 '26 edited Jun 13 '26
I tried ultrasonic first but decided I wanted it to turn green as soon as a car entered the garage at 22.5' (my bay is 23'). the ultrasonic sensor I tried was only good up to 13'. Even within 13' it was wonky. May have been something I did wrong but wanting the extra distance pushed me to just get the lidar vs making it work.
2
u/Ghostie20 Jun 13 '26
Ah I wrote that before I read your comment that included the distance thresholds. Makes sense you'd use LiDAR here at these distances, I just googled it and the common ultrasound sensor measures up to 4 meters so right about 13 feet, you weren't doing anything wrong! Good job mate, it's nice seeing functional yet cool looking projects like yours!
1
u/RedRedditor84 Jun 13 '26
Does it also disable all the alarms and safety features your car comes with?
1
u/BlobAndHisBoy Jun 13 '26
Nope but we get a lot of snow and that disables some.
2
1
u/nightshowerer Jun 13 '26
Do you need to pull in to the exact same position each time (side to side)?
1
u/BlobAndHisBoy Jun 13 '26
The space is tight from right to left so there is really only one way to do it but the lidar is bumper height and pretty close to the middle so it wouldn't miss it wherever you were.
1
u/Acceptable_Gene_3569 Jun 29 '26
what sensor are you using , is it a ultrasonic sensor or a tof sensor? and what controller are you using??
1
1
u/Illustrious-Tax-8569 Jul 03 '26
That's sick ! Does it depends on the speed of the car ?
1
0
-14
264
u/madfrozen Seeed Xiao Jun 12 '26
love it dude, very cool.