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.

Image of a range finder sensor displaying detected object distance and status on a V5 Brain screen.

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.

Illustration of a range finder sensor displaying distance measurements and object detection status on a screen.

Choose which Ultrasonic Range Finder Sensor to use.

Image of a range finder distance device used for detecting object distance in robotics applications.

Choose which unit to report in: millimeters (mm) or inches.

Image showing distance units for a range finder sensor, illustrating measurement options in a robotics context.

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