LED Ring Distance Sensor

4,243

52

9

Introduction: 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)

Supplies

Arduino (I used Uno)

distance sensor (HC-SR04)

Neopixel ring

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.

HC-SR04:

  • 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:

https://github.com/the-developer-guy/FastLED_Color...

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

Participated in the
Robotics Contest

Be the First to Share

    Recommendations

    • Explore Science Challenge

      Explore Science Challenge
    • Box Challenge

      Box Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest

    9 Comments

    0
    ramir28
    ramir28

    Question 1 year ago on Introduction

    Hi there,

    Where can I find the code for the LED Ring Distance Sensor. I am using an Arduino uno and Adafruit Neopixel Ring 16 by 5050 RGB LED with integreated drives [ADA1463]. I did look up on your Github but was not able to find it. Can you assist with the Arduino Code?

    Thank you.

    0
    sumitpatil8680
    sumitpatil8680

    Reply 1 year ago

    Please guide me for making LVDT with aurdino nano

    0
    thedeveloperguy
    thedeveloperguy

    Reply 1 year ago

    I'm terribly sorry, but I never did LVDT and I'm currently too busy with other projects.

    0
    adeckert1010
    adeckert1010

    1 year 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?

    0
    thedeveloperguy
    thedeveloperguy

    Reply 1 year ago

    Well, if you add your own led driver instance in the ColorBar class, adjust the led array to support RGBW and let display() do the trick on your led driver, it should work.

    1
    gravityisweak
    gravityisweak

    1 year 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!

    0
    thedeveloperguy
    thedeveloperguy

    Reply 1 year ago

    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)