Introduction: Multi-Purpose Light Distance Sensor

There are multiple ways to use an amazing creation such as this Light Distance Sensor! The reason I decided to create this was for my After-School Coding Class with 6th graders. The students are working with their Sphero Ollies and learning how to use block coding to program Some students are learning only the basics but others are really advanced and trying their best to zero in on precise movements and codes. They use protractors and meter/yard sticks to help with measurements of courses, paths and even objects they are trying to code their Ollie to recreate. Using this Light Distance Sensor would help with precise code and could also help in providing a fun way to determine who accomplishes a task within a certain distance required without using a ruler. This is a beginner-level project that comes with step-by-step instructions that make it easy to accomplish!

The ultrasonic sensor picks up an object's distance from its sensor by sending ultrasound waves from the sensor that bounce off the object and return to the sensor. These waves, based on the time it takes it to travel there and back, in addition to the speed it travels, calculate the distance. The distance is represented on the breadboard through the RGB LED light, with the shades representing distances (in centimeters) as follows:

  • Red: greater than 125 cm
  • Green: greater than 100 and less than or equal to 125 cm
  • Blue: greater than 75 and less than or equal to 100 cm
  • Yellow: greater than 50 and less than or equal to 75 cm
  • Purple: greater than 25 and less than or equal to 50 cm
  • Aqua: greater than 0 and less than or equal to 25 cm

*These distances can be altered to smaller or larger increments and distances depending on the task you're looking to accomplish.

Step 1: Components and Getting Started

You will need the following supplies to create your own Multipurpose Ultrasonic Light Distance Sensor:

  • breadboard
  • Arduino
  • 9 jumper cables
  • 1 RGB LED
  • 3-330 Ohm Resistors
  • 1 Ultrasonic Distance Sensor
  • Power Source- computer and optional battery power source
  • USB connector to connect and run code from computer
  • Optional: remote control car to attach Arduino to when finished.

No tools necessary!

Start by connecting power to the breadboard power rail from the 5V pin on your Arduino and the ground rail to the GND pin on your Arduino.

Step 2: Connecting the Ultrasonic Sensor

You will connect your Ultrasonic Sensor next.

  1. Connect a jumper cable from the GND on the sensor to the ground rail on your breadboard
  2. Connect the Echo to the 7 pin on the Arduino
  3. Connect the Trig to the 8 pin on the Arduino
  4. Connect the VCC to the power rail on your breadboard.

*Note: this looks slightly different than the set up on the TinkerCad diagram due to my Ultrasonic Sensor being a different brand than the one shown on the program. See the pictures for a more accurate set-up guide.

Step 3: Connecting the RGB LED

Next you will connect the RGB LED light. Remember, the longest leg is the GND- see RGB LED image as a guide. Connect your LED using the TinkerCad image and photo above.

  • redPin: 11
  • (-): GND rail
  • greenPin: 10
  • bluePin: 9

Step 4: The Code

Next you will need to connect your Arduino to the computer and download the code to run this program. Click here for the link to the code. Try out your creation!

HELPFUL TIPS:

  1. Take a look at the comments in the code that indicate where you can change distance increments. Also, you can choose to change the order in which the LED's colors turn, if preferred.
  2. Use the "Monitor" in Arduino Editor to track actual distances while the code is running on your Arduino, as long as you are plugged in to the computer and not just a battery source.
  3. I attached my finished Arduino to a remote control car to show the changes in distances fluidly. This is not permanent and can be moved or detached to be re-purposed.

Step 5: Other Purposes and Resources

Here are some other ways the Ultrasonic Distance Light Sensor can work for you:

  • teaching measurement
  • estimating measurement
  • monitoring students distance from a teacher's desk (I have a difficult time with students behind my desk or taking things from my desk when I am not sitting there....this would be great with a buzzer installed too!)
  • range-finder for archery target practice
  • bike parking in the garage
  • game of hot/cold

Resources:

Author Unknown. (2018). How to Mechatronics. Retrieved from: https://howtomechatronics.com/arduino-projects/

E. Chen. (date unknown). Ultrasonic Ranging Module HC - SR04 & RGB LED Emitter. Retrieved from Summerfuel Robotics: https://sites.google.com/site/summerfuelrobots/ard...

Joel_E_B. (date unknown). SparkFun Inventor's Kit Experiment Guide - v4.0: Circuit 1D: RGB Night-Light. Retrieved from: https://learn.sparkfun.com/tutorials/sparkfun-inve...