Range Finder Sensing#
To make Range Finder Sensor blocks appear in VEXcode V5, a 3-Wire UltraSonic Range Finder Sensor must be configured in the Devices window.
For more information, refer to these articles:
Range Finder Found Object?#
The Range Finder Found Object? block is used to report if the Ultrasonic Range Finder Sensor sees an object within its field of view.
<[RangeFinderE v] found an object?>
The Range Finder Found Object? block reports True
when the Ultrasonic Range Finder Sensor sees an object or surface within its field of view.
The Range Finder Found Object? block reports False
when the Ultrasonic Range Finder Sensor does not detect an object or surface.
Choose which Ultrasonic Range Finder Sensor to use.
In this example, every .25 seconds the Range Finder will check if it detects an object, and if so, will print the distance between it and the object to the Brain’s Screen.
when started :: hat events
forever
clear all rows on [Brain v]
set cursor to row (1) column (1) on Brain :: #9A67FF
[Check if the Range Finder found an object.]
if <[RangeFinderE v] found an object?> then
[Print the distance to the object.]
print ([RangeFinderE v] distance in [mm v]) on [Brain v] ◀ and set cursor to next row
end
[Repeat the process every .25 seconds.]
wait (0.25) seconds
end
Range Finder Distance#
The Range Finder Distance block is used to report the distance of the nearest object from the Ultrasonic Range Finder Sensor.
Choose which Ultrasonic Range Finder Sensor to use.
Choose which unit to report in: millimeters (mm) or inches.
In this example, every .25 seconds the Range Finder will check if it detects an object, and if so, will print the distance between it and the object to the Brain’s Screen.
when started :: hat events
forever
clear all rows on [Brain v]
set cursor to row (1) column (1) on Brain :: #9A67FF
[Check if the Range Finder found an object.]
if <[RangeFinderE v] found an object?> then
[Print the distance to the object.]
print ([RangeFinderE v] distance in [mm v]) on [Brain v] ◀ and set cursor to next row
end
[Repeat the process every .25 seconds.]
wait (0.25) seconds
end