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