Ultrasonic Sensor Block

The Ultrasonic Sensor block gets data from the Ultrasonic Sensor. You can measure the distance in either inches or centimeters and get a Numeric output. You can also compare the distance to a Threshold Value to get a Logic (True or False) output. You can also detect other ultrasonic signals in “listen only” mode.

See Using the Ultrasonic Sensor help for more information about what the Ultrasonic Sensor does, the data that it provides, and programming examples.
Tips and Tricks
The Ultrasonic Sensor block outputs data with a Data Wire. See Using the Ultrasonic Sensor for other ways to use the Ultrasonic Sensor that don’t require a data wire.
Choose the Sensor Port and Mode



Port Selector
Mode Selector
Inputs
Outputs

Use the Port Selector on the top of the block to make sure that the sensor port number (1, 2, 3, or 4) matches the port on the EV3 Brick that the Ultrasonic Sensor is connected to.

Use the Mode Selector to select the mode for the block. The Inputs and Outputs available will change depending on the mode.
Modes
Measure – Distance Centimeters


The Measure – Distance Centimeters mode outputs the distance in centimeters in the Distance in Centimeters."
Measure – Distance Inches


The Measure – Distance Inches mode outputs the distance in inches in the Distance in Inches."
Measure – Presence


The Measure – Presence mode listens for other ultrasonic signals in “listen only” mode. The Ultrasound Detected output will be True if a signal is detected, otherwise False.
Compare – Distance Centimeters


The Compare – Distance Centimeters mode compares the distance in centimeters to the Threshold Value using the selected Compare Type. The True/False result is output in Compare Result, and the distance in centimeters is output in Distance in Centimeters."
Compare – Distance Inches


The Compare – Distance Inches mode compares the distance in inches to the Threshold Value using the selected Compare Type. The True/False result is output in Compare Result, and the distance in inches is output in Distance in Inches.
"
Compare – Presence/Listen


The Compare – Presence/Listen mode listens for other ultrasonic signals in “listen only” mode. The Ultrasound Detected output will be True if a signal is detected, otherwise False."
Measure – Advanced - Centimeters


The Measure – Advanced – Centimeters mode is similar to the Measure – Distance Centimeters mode, except that you can choose whether the sensor sends a single ultrasonic signal or continuous signals with the Measuring Mode input. The distance in centimeters is output in the Distance in Centimeters."
Measure – Advanced - Inches


The Measure – Advanced – Inches mode is similar to the Measure – Distance Inches mode, except that you can choose whether the sensor sends a single ultrasonic signal or continuous signals with the Measuring Mode input. The distance in inches is output in the Distance in Inches."
Tips and Tricks
In the Measure – Distance Centimeters and Measure – Distance Inches modes, the sensor always sends a continuous ultrasonic signal.
Inputs and Outputs
The inputs available for the Ultrasonic Sensor block will depend on the mode selected. You can enter the input values directly into the block. Alternatively, the input values can be supplied by Data Wires from the outputs of other Programming Blocks.
InputTypeAllowed ValuesNotes
Compare Type Numeric0 - 50: = (Equal to)
1: ≠ (Not Equal to)
2: > (Greater than)
3: ≥ (Greater than or Equal to)
4: < (Less than)
5: ≤ (Less than or Equal to)
Threshold Value NumericAny numberValue to compare sensor data to
Measuring Mode Numeric0 or 1Ultrasonic signal mode in Advanced modes:
0 = Ping
1 = Continuous
The outputs available will depend on the mode selected. To use an output, use a Data Wire to connect it to another Programming Block.
OutputTypeNotes
Distance in Centimeters NumericDistance in centimeters (0-255 cm).
Distance in Inches NumericDistance in inches (0-100 in).
Ultrasound Detected LogicTrue if an ultrasonic signal is detected, otherwise False.
Compare Result LogicTrue/False result of a Compare mode.
Ultrasonic
Quick links