Main Content

Ultrasonic Sensor

Represent connected Ultrasonic sensor and measure distance to object

  • Library:
  • Simulink Coder Support Package for VEX EDR V5 Robot Brain / Sensors

  • Ultrasonic Sensor block


The Ultrasonic Sensor block represents an Ultrasonic Sensor that is connected to the 3-wire ports of VEX EDR V5 Robot Brain, and measure the distance to the object in the path of the robot. The block enables the object detection when the object is in the range of 3 to 300 centimeters (cm) from the sensor. The block outputs a value 0 for an object that is farther than 300 cm.



expand all

The distance (in cm) as read from the Echo port of the Ultrasonic Sensor connected to VEX V5 Robot Brain.

Data Types: double


expand all

If you are using a 3-Wire Expander, specify the smart port on VEX® EDR V5 Robot Brain to which the expander is connected.

Select the 3-wire port of VEX V5 Robot Brain to which the Echo port (output) of Ultrasonic sensor is connected. To know the output port, click the What is INPUT and OUTPUT? button.

After you select the OUTPUT (Echo port) in the block, the consecutive 3-wire port is assumed to be connected to the INPUT (Ping port) of the ultrasonic sensor. For example, if you select A as the OUTPUT (Echo port), it is assumed that B is connected to the INPUT (Ping) port of the ultrasonic sensor.

Enter the time interval at which the block reads values from the ultrasonic sensor.

When you set this parameter to -1, Simulink® determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2019b