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.

Step 1: What You Will Need

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

Step 2: The Circuit

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

Step 3: Start Visuino, and Select the Arduino UNO Board Type

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

Step 4: In Visuino Add Components

  • 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

Step 5: In Visuino Set Components

  • 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

Step 6: In Visuino Connect Components

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

Step 7: Generate, Compile, and Upload the Arduino Code

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)

Step 8: 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

Read Full tutorial here.