Programming instructions

Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Thresholds 1
If you look at this image, it shows an VEX using an Ultrasonic Rangender. The threshold in
this case is 25 centimeters. We can create behaviors that tell the robot to go forward until the
Ultrasonic Rangender detects something closer than 25 centimeters.
The threshold is just used to determine at which point the robot should be peforming a
different behavior.
Calculated Thresholds
Some sensors, like the Ultrasonic Rangender and Potentiometer, provide the same set of
values no matter what environment the robot is in; for the most part, their thresholds can simply
be chosen based on their application. Other sensors, like the Light Sensor and Line Tracking
Sensor, will provide very different values based on the environment they’re in, due to factors
such as the amount of ambient light or the type of surface the robot is tracking. Sensors that
provide a different range of values based on their environment need to have their thresholds
calculated.
For example, to nd a dark line on a light surface, you must rst calculate a threshold to
distinguish light from dark. One recommended method is:
1. Meausre the Line Follower Sensor value of the light surface. (For more information on nding
sensor values, reference the ROBOTC Debugger document.)
2. Measure the Line Follower Sensor value of the dark surface
3. Add the two light sensor readings together
4. Divide by two to nd the average, and use it as your threshold
In equation form:
Thresholds are values that set a cutoff in a range of values, so that even if there are many
possibilities, the value eventually falls above the threshold, or below the threshold. Using
thresholds allows you to perform certain behaviors depending on where a certain value
(usually a sensor value) falls in relation to the threshold.
Threshold = 25 cm
Near Far
light value + dark value
2
= threshold
startMotor(leftMotor, 63);
untilSonarLessThan(25);
Thresholds with Natural Language
Go to Reference Links