Arduino LED Ring Ultrasonic Distance Sensor

by RonFrtek in Circuits > Arduino

2485 Views, 5 Favorites, 0 Comments

Arduino LED Ring Ultrasonic Distance Sensor

Arduino LED Ring Ultrasonic Distance Sensor

In this tutorial we will learn how to Use a LED ring with and a Ultrasonic module to measure the distance.

Watch a demonstration video.

What You Will Need

16-x-ws2812-5050-rgb-led-ring-with-integrated-drivers-neopixel-compatible.jpg
DIY4002.jpg
VisuinoAdvrtisementM5Stack6.jpg
arduino-uno-rev-3.jpg
jumper-wires.jpg
FXQ4NRRJJ4ZYFIT.LARGE.jpg

  • Arduino UNO (or any other Arduino)
  • Ultrasonic Range Finder HC-SR04
  • Jumper wires
  • Neopixel LED ring
  • Visuino program: Download Visuino

The Circuit

2020-01-13_10-08-50.jpg

  • Connect LED Ring pin [VCC] to Arduino pin [+5V]
  • Connect LED Ring pin [GND] to Arduino pin [GND]
  • Connect LED Ring pin [IN] or (DI) to Arduino digital pin [6]
  • Connect Ultrasonic module pin (VCC) to Arduino pin [+5V]
  • Connect Ultrasonic module pin (GND) to Arduino pin [GND]
  • Connect Ultrasonic module pin (ECHO) to Arduino pin digital (3)
  • Connect Ultrasonic module pin (TRIG) to Arduino pin digital (2)

Start Visuino, and Select the Arduino UNO Board Type

FL8QFGAK5H5EPPK.LARGE.jpg
FBL8FPKK5H5EPPI.LARGE.jpg

To start programming the Arduino, you will need to have the Arduino IDE installed from here: https://www.arduino.cc/.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work! If you have not done follow the steps in this Instructable to setup the Arduino IDE to program Arduino UNO! The Visuino: https://www.visuino.eu also needs to be installed. Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2020-01-23_16-03-04.jpg
2020-01-23_16-03-39.jpg
2020-01-23_16-04-35.jpg
2020-01-23_16-07-25.jpg
  • Add "Ultrasonic Ranger(Ping)" component
  • Add "NeoPixels" component
  • Add "Ramp To Analog Value" component
  • Add "Analog To Unsigned" component
  • Add 2X "Compare Analog Value" component
  • Add 2X "Color Value" component
  • Add "RGBW Color Multi-Source Merger" component

In Visuino Set Components

2020-01-23_16-13-09.jpg
F0DH72WK4K5OI6F.LARGE.jpg
F46J06IK4K5OI6G.LARGE.jpg
FTBBO8EK4K5OI6E.LARGE.jpg
  • Select "RampToValue1" and in the properties window set "Slope (S)" to 1000
  • Select "CompareValue1" and in the properties window set "Compare Type" to ctBigger and "Value" to 10
    -Select the "Value" field and Click on the pin icon and select "Float SinkPin"
  • Select "CompareValue2" and in the properties window set "Compare Type" to ctSmaller
    -Select the "Value" field and Click on the pin icon and select "Float SinkPin"
  • Select "ColorValue1" and in the properties window set "Value" to clRed
  • Select "ColorValue2" and in the properties window set "Value" to clLime
  • Double click on the "NeoPixels1" and in the "PixelGroups" window drag "Color Pixel" to the left
    On the left side of the "PixelGroups" window then select "Color Pixel1" and in the properties window set "Count Pixels" to 12 or 16 (Depends on how many LED your LED ring is having)
    -You can change the LED brightness if you want by changing the value in the "Brightness" field

In Visuino Connect Components

UZ-ringled.png
  • Connect "UltrasonicRanger1" pin [Ping(Trigger)] to Arduino digital pin[2]
  • Connect "Arduino" digital pin[3] Out to "UltrasonicRanger1" pin [Echo]
  • Connect "NeoPixels1" pin [Out] to Arduino digital pin[6]
  • Connect "UltrasonicRanger1" pin [Out] to "RampToValue1" pin[In] and "CompareValue1" pin[Value] and "CompareValue2" pin[Value]
  • Connect "RampToValue1" pin[Out] to "AnalogToUnsigned1" pin [In] and "CompareValue1" pin[In] and "CompareValue2" pin[In]
  • Connect "CompareValue1" pin[Out] to "ColorValue1" pin[clock]
  • Connect "CompareValue2" pin[Out] to "ColorValue2" pin[clock]
  • Connect "ColorValue1" pin[Out] to "RGBWColorMultiMerger1" Pin[0]
  • Connect "ColorValue2" pin[Out] to "RGBWColorMultiMerger1" Pin[1]
  • Connect "RGBWColorMultiMerger1" pin [Out] to "NeoPixels1">Color Pixel1 pin[Color]
  • Connect "AnalogToUnsigned1" to "NeoPixels1">Color Pixel1 pin[U32 Index]

Generate, Compile, and Upload the Arduino Code

F7PZ4XBK5H5ERJK.LARGE.jpg
FVS3Y85JJ4ZYH0Q.LARGE.jpg

In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE

In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Play

If you power the Arduino UNO module, the LED ring should start showing the range distance, and if you add an obstacle in front of the range finder module the LED ring should change its color.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu