LED Ring Distance Sensor




About: Teaching and making electronics since - well I don't even know

Hello there, this is The Developer Guy, and let me introduce You to this very short, but fun project, which will end up in an alternative parking sensor.

Yes, you COULD write the measured distance on an LCD display. Yes, you CAN use a different distance sensor and YES, you can use different LED rings too. This project is about showing an alternative. (oh, and of course any Arduino compatible board is fine if it handles the FastLED lib)


Arduino (I used Uno)

distance sensor (HC-SR04)

Neopixel ring

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Wiring

It's really not much to see here, the magic is in the code: both the distance sensor and the LED ring is easy to use.


  • VCC <--> 5V
  • GND <--> GND
  • Trigger <--> Pin 7
  • Echo <--> Pin 2

While the trigger signal can be produced by practically any digital IO pin and you can freely change it, the Echo should be on an interrupt capable pin - the sample code I give you uses an interrupt to measure distance (time * speed of sound).

LED ring or strip:

  • VCC <--> 5V
  • GND <--> GND
  • DIN/Data in <--> Pin 3

Step 2: Uploading the Code

Because it depends on FastLED, get that library first. (search for FastLED in the Library manager)

Get the latest version of my code from GitHub:


Copy the contents to your Arduino/libraries/FastLED_ColorBar folder, so the Arduino IDE will detect it. If successfully detected, the sample code can be opened from File/Examples/FastLED_ColorBar/HC-SR04-distance.

You can change the pins if needed, but check your LED type (it has NEOPIXEL by default, should work with yours too) and adjust the LED count.

Now upload the code!

Step 3: Testing!

Now ready to test!

There is no filtering in the code, if any glitch or wrong measurement is made, it will display wrong data.

I hope you liked this instructable!

Robotics Contest

This is an entry in the
Robotics Contest

Be the First to Share


    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    3 Discussions


    17 hours ago

    I ended up with an adafruit neopixel rgbw ring. I only just now found out that fastled doesn't support rgbw. Do you know of another way to get this project to work?


    3 days ago

    This is great! I have an old traffic light and have always toyed with the idea of hanging it in my garage and using similar code to have it be green when the garage door opens, turn to yellow when I'm within a few feet, then finally red when I'm close to the sensor. I love your build!

    1 reply

    Thanks pal! For cars, I would suggest a laser sensor: https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html
    As an engineer, I would be ashamed if this build would cause a dent or scratch on a car!
    Also for a traffic light, I'd suggest hardcoded values, validity check and basic filtering of the measured values.
    I would LOVE to see your build in action! (we park in a huge open space so I can't demonstrate)