ronfrtek
Created February 1, 2020 © LGPL

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.

IntermediateProtip1 hour1
Arduino LED Ring Ultrasonic Distance Sensor

Things used in this project

Story

Read more

Schematics

Project File

Code

neo-pixel-distance-ultrasound.visuino

Arduino
{
  "Version": "2",
  "Product": "Visuino Pro - Visual Arduino Programming",
  "Units": [
    {
      "Type": "Diagram",
      "Name": "__OpenWireRootUnit__",
      "*": [
        {
          "X": 1280,
          "Name": "Arduino",
          "Instance": {
            "Serial": {
              "*": [
                {
                  "+": "TArduinoHardwareSerial"
                }
              ]
            },
            "+": "TArduinoBoard",
            "AnalogInputReference": "Default",
            "Modules": {
              "*": [
                {
                  "+": "TArduinoEEPROMModule"
                },
                {
                  "+": "TArduinoProcessor328Module"
                },
                {
                  "+": "TArduinoWatchdogTimerModule"
                }
              ]
            },
            "I2CChannels": {
              "*": [
                {
                  "+": "TArduinoI2C"
                }
              ]
            },
            "Digital": {
              "*": [
                {
                  "+": "TArduinoAdditionalDigitalSerial0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalSerial0Channel"
                },
                {
                  "DigitalInputPin": {
                    "SourcePin": {
                      "Name": "__OpenWireRootUnit__.UltrasonicRanger1.Ping(Trigger)",
                      "ID": "__OpenWireRootUnit__.UltrasonicRanger1.PingOutputPin"
                    }
                  },
                  "+": "TArduinoAdditionalDigitalInterruptChannel"
                },
                {
                  "OutputPin": {
                    "SinkPins": [
                      {
                        "ID": "__OpenWireRootUnit__.UltrasonicRanger1.EchoInputPin"
                      }
                    ]
                  },
                  "+": "TArduinoBasicDigitalPWMInterruptChannel"
                },
                {
                  "+": "TArduinoAdditionalDigitalChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "DigitalInputPin": {
                    "SourcePin": {
                      "ID": "__OpenWireRootUnit__.NeoPixels1.OutputPin"
                    }
                  },
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoAdditionalDigitalChannel"
                },
                {
                  "+": "TArduinoAdditionalDigitalChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMChannel"
                },
                {
                  "+": "TArduinoBasicDigitalPWMSPI0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalSPI0Channel"
                },
                {
                  "+": "TArduinoAdditionalDigitalSPI0Channel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalChannel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalI2C0Channel"
                },
                {
                  "+": "TArduinoCombinedAnalogDigitalI2C0Channel"
                }
              ]
            },
            "SPIChannels": {
              "*": [
                {
                  "+": "TArduinoSPI"
                }
              ]
            },
            "BoardType": "Arduino Uno"
          },
          "Type": "Component",
          "Y": 256
        },
        {
          "X": 832,
          "Name": "UltrasonicRanger1",
          "Instance": {
            "OutputPin": {
              "SinkPins": [
                {
                  "ID": "__OpenWireRootUnit__.RampToValue1.InputPin"
                },
                {
                  "Name": "__OpenWireRootUnit__.CompareValue1.Value",
                  "ID": "__OpenWireRootUnit__.CompareValue1.ValueInputPin"
                },
                {
                  "Name": "__OpenWireRootUnit__.CompareValue2.Value",
                  "ID": "__OpenWireRootUnit__.CompareValue2.ValueInputPin"
                }
              ]
            },
            "EchoInputPin": {
              "SourcePin": {
                "Name": "__OpenWireRootUnit__.Arduino.Digital.Digital[ 3 ].OutputPin",
                "ID": "__OpenWireRootUnit__.Arduino.Digital._Item3.OutputPin"
              }
            },
            "+": "TArduinoUltrasonicRanger",
            "PingOutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.Arduino.Digital.Digital[ 2 ].DigitalInputPin",
                  "ID": "__OpenWireRootUnit__.Arduino.Digital._Item2.DigitalInputPin"
                }
              ]
            }
          },
          "Type": "Component",
          "Y": 448
        },
        {
          "X": 1008,
          "Name": "NeoPixels1",
          "Instance": {
            "PixelGroups": {
              "*": [
                {
                  "Name": "Color Pixel1",
                  "IndexInputPin": {
                    "SourcePin": {
                      "ID": "__OpenWireRootUnit__.AnalogToUnsigned1.OutputPin"
                    }
                  },
                  "+": "TArduinoNeoPixelsColorPixelGroup",
                  "ColorInputPin": {
                    "SourcePin": {
                      "ID": "__OpenWireRootUnit__.RGBWColorMultiMerger1.OutputPin"
                    }
                  },
                  "CountPixels": 16
                }
              ]
            },
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.Arduino.Digital.Digital[ 6 ].DigitalInputPin",
                  "ID": "__OpenWireRootUnit__.Arduino.Digital._Item6.DigitalInputPin"
                }
              ]
            },
            "+": "TArduinoNeoPixels",
            "Brightness": 0.401123046875
          },
          "Type": "Component",
          "Y": 880
        },
        {
          "X": 464,
          "Name": "ColorValue1",
          "Instance": {
            "ClockInputPin": {
              "SourcePins": [
                {
                  "ID": "__OpenWireRootUnit__.CompareValue1.OutputPin"
                }
              ]
            },
            "Value": 255,
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.RGBWColorMultiMerger1.InputPins.Pin [0]",
                  "ID": "__OpenWireRootUnit__.RGBWColorMultiMerger1.InputPins._Pin0"
                }
              ]
            },
            "+": "TArduinoColorValue"
          },
          "Type": "Component",
          "Y": 816
        },
        {
          "X": 608,
          "Name": "RampToValue1",
          "Instance": {
            "InputPin": {
              "SourcePin": {
                "ID": "__OpenWireRootUnit__.UltrasonicRanger1.OutputPin"
              }
            },
            "OutputPin": {
              "SinkPins": [
                {
                  "ID": "__OpenWireRootUnit__.AnalogToUnsigned1.InputPin"
                },
                {
                  "ID": "__OpenWireRootUnit__.CompareValue1.InputPin"
                },
                {
                  "ID": "__OpenWireRootUnit__.CompareValue2.InputPin"
                }
              ]
            },
            "+": "TArduinoRampToValue",
            "Slope": 1000
          },
          "Type": "Component",
          "Y": 608
        },
        {
          "X": 768,
          "Name": "AnalogToUnsigned1",
          "Instance": {
            "InputPin": {
              "SourcePin": {
                "ID": "__OpenWireRootUnit__.RampToValue1.OutputPin"
              }
            },
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.NeoPixels1.PixelGroups.Color Pixel1.IndexInputPin",
                  "ID": "__OpenWireRootUnit__.NeoPixels1.PixelGroups._Item0.IndexInputPin"
                }
              ]
            },
            "+": "TArduinoFloatToUnsigned"
          },
          "Type": "Component",
          "Y": 608
        },
        {
          "X": 720,
          "Name": "RGBWColorMultiMerger1",
          "Instance": {
            "InputPins": {
              "Form": "__OpenWireRootUnit__",
              "Pins": [
                {
                  "Type": "ptSink",
                  "SourcePin": {
                    "ID": "__OpenWireRootUnit__.ColorValue1.OutputPin"
                  }
                },
                {
                  "Type": "ptSink",
                  "SourcePin": {
                    "ID": "__OpenWireRootUnit__.ColorValue2.OutputPin"
                  }
                }
              ]
            },
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.NeoPixels1.PixelGroups.Color Pixel1.ColorInputPin",
                  "ID": "__OpenWireRootUnit__.NeoPixels1.PixelGroups._Item0.ColorInputPin"
                }
              ]
            },
            "+": "TArduinoRGBWColorMultiMerger"
          },
          "Type": "Component",
          "Y": 864
        },
        {
          "X": 256,
          "Name": "CompareValue1",
          "Instance": {
            "Value": 10,
            "OutputPin": {
              "SinkPins": [
                {
                  "ID": "__OpenWireRootUnit__.ColorValue1.ClockInputPin"
                }
              ]
            },
            "+": "TArduinoCompareValue",
            "InputPin": {
              "SourcePin": {
                "ID": "__OpenWireRootUnit__.RampToValue1.OutputPin"
              }
            },
            "CompareType": "ctBigger",
            "@": [
              {
                "PinName": "Value",
                "@": "Value",
                "+": "TOWSingleSinkPinBinding",
                "SourcePin": {
                  "ID": "__OpenWireRootUnit__.UltrasonicRanger1.OutputPin"
                },
                "Component": "CompareValue1"
              }
            ]
          },
          "Type": "Component",
          "Y": 816
        },
        {
          "X": 272,
          "Name": "CompareValue2",
          "Instance": {
            "InputPin": {
              "SourcePin": {
                "ID": "__OpenWireRootUnit__.RampToValue1.OutputPin"
              }
            },
            "OutputPin": {
              "SinkPins": [
                {
                  "ID": "__OpenWireRootUnit__.ColorValue2.ClockInputPin"
                }
              ]
            },
            "+": "TArduinoCompareValue",
            "CompareType": "ctSmaller",
            "@": [
              {
                "PinName": "Value",
                "@": "Value",
                "+": "TOWSingleSinkPinBinding",
                "SourcePin": {
                  "ID": "__OpenWireRootUnit__.UltrasonicRanger1.OutputPin"
                },
                "Component": "CompareValue2"
              }
            ]
          },
          "Type": "Component",
          "Y": 928
        },
        {
          "X": 464,
          "Name": "ColorValue2",
          "Instance": {
            "ClockInputPin": {
              "SourcePins": [
                {
                  "ID": "__OpenWireRootUnit__.CompareValue2.OutputPin"
                }
              ]
            },
            "Value": 65280,
            "OutputPin": {
              "SinkPins": [
                {
                  "Name": "__OpenWireRootUnit__.RGBWColorMultiMerger1.InputPins.Pin [1]",
                  "ID": "__OpenWireRootUnit__.RGBWColorMultiMerger1.InputPins._Pin1"
                }
              ]
            },
            "+": "TArduinoColorValue"
          },
          "Type": "Component",
          "Y": 944
        }
      ]
    }
  ],
  "Content": "OpenWire Diagram"
}

Credits

ronfrtek

ronfrtek

13 projects • 4 followers
Arduino Fan!

Comments