The VEX IQ Distance Sensor
Read about the Distance Sensor
To learn more about the Distance Sensor, ask the Reader to organize how the group will read the VEX IQ Distance Sensor article from the VEX Library. This article will cover how the Distance Sensor works and provide common uses.
Program with the Distance Sensor
Have the Programmer open VEXcode IQ and follow these steps:
-
Begin by opening the Testbed template example project from VEXcode IQ.
- For help opening the example project, view the Use Example Projects and Templates tutorial video.
-
Build the following project and save it (macOS, Windows, Chromebook, iPad) as Distance Sensor:
Test the Distance Sensor
Have the Tester connect the VEX IQ Brain to your computer and then follow these steps:
- Download the project to the IQ Robot Brain.
- Run the project to report if the Distance Sensor detects an object or not. If it does, it reports how far away it is from the sensor.
- For help downloading and running a project, view the Download and Run a Project tutorial video.
- Based on your observations of how the sensor behaved on the Testbed and the information from the reading, answer the following questions and ask the Recorder to document them in your engineering notebook:
- In what scenario would you use a Distance Sensor instead of a Bumper Switch?
- Why might you want a robot to detect objects at a distance?
Teacher Toolbox
-
Answers
The following answers may vary:
-
A Distance Sensor can be used to stop or slow down a robot before it collides with an object. A Bumper Switch would first have to collide with an object to press the switch before an action would happen. Using the Distance Sensor can be used to prevent any collision at all.
-
Using the Distance Sensor to detect objects from a distance can allow the robot to slow down as it approaches the object, stop before making contact with an object, or maintain a specific distance between it and the object. It can also be used to move the robot away from an object to a specific distance.
Teacher Tips
If students are having trouble understanding how the distance sensor works, compare it to how bats use echolocation. Bats send sound waves through the air and the energy bounces back when it hits an object, telling the bat where and how far away it is.
Teacher Toolbox
-
Troubleshooting
When working with the Distance Sensor, there could be instances where it does not behave as it should. If this occurs, begin troubleshooting by trying the following steps:
-
First begin by checking that the Distance Sensor's firmware is up-to-date. Read this article for more information on how to update firmware.
-
If the firmware is up to date, further look into the Device Info screen on the IQ Brain to check if an object is being detected or not. If an object is detected, it should display how far away that object is in millimeters and inches. Use the article, “How to Troubleshoot VEX IQ Sensors.”
-
If the Device Info reports accurate values, the issue could be that the student miscopied the project.
-
To troubleshoot the project, check that the device is configured properly - meaning that they used the correct Testbed example project. For more information on how to configure the Distance Sensor, read the "How to Configure VEX IQ Sensors - VEXcode IQ" article.
-
Ensure that the students copied and built the project correctly. You can use the print block in VEXcode IQ to display the current sensor values on the Brain as the project proceeds through to the error or to the end of the project.
-
-
If the Device Info does NOT report accurate values, then the issue could be hardware-related.
-
To troubleshoot the hardware, try checking the port connection with the Smart Cable using the article, “How to Connect VEX IQ Devices to Smart Ports.”
-
If the Distance Sensor is connected properly and it is still not behaving as it should, there could be a physical issue with the Distance Sensor. Test switching it out with another Distance Sensor.
-
Motivate Discussion
To help students think about how the Distance Sensor can help a robot, ask students the following questions:
Q: If you compared the Distance Sensor to a part of the human body, which part would it be and why?
A: Students should answer with eyes, because our eyes help gauge how far away objects are. We use this sensory data from our eyes to determine how to move, which is what the Distance Sensor data does for the robot.
Q: Using the Distance Sensor, what types of tasks could you program a robot to complete?
A: Students answers will only be limited by their imaginations. Students could respond with robots which use distance sensors to navigate mazes or obstacles, race a course, find objects, and many more ideas. The type of robot they imagine using the distance sensor would impact the use of the distance sensor as well.