Ev3UltrasonicSensor
Last Updated On 2021-07-16
Version 2MinSDK 7Tutorial Video
A component that provides a high-level interface to an ultrasonic sensor on a LEGO MINDSTORMS EV3 robot.
Properties
You can set the below properties in the UI part of the builder.
- AboveRangeEventEnabled - it's a boolean value which is set to false by default.
- BelowRangeEventEnabled - it's a boolean value which is set to false by default.
- BluetoothClient - it's a BluetoothClient value which is set to blank by default.
- BottomOfRange - it's a non negative integer value which is set to 30 by default.
- SensorPort - it's a lego ev3 sensor port value which is set to 1 by default.
- TopOfRange - it's a non negative integer value which is set to 90 by default.
- Unit - it's a lego ev3 ultrasonic sensor mode value which is set to cm by default.
- WithinRangeEventEnabled - it's a boolean value which is set to false by default.
Block Properties
You can set the below blocks properties in the blocks section of the builder.
AboveRangeEventEnabled
Whether the AboveRange event should fire when the distance goes above the TopOfRange.
BelowRangeEventEnabled
Whether the BelowRange event should fire when the distance goes below the BottomOfRange.
BluetoothClient
The BluetoothClient component that should be used for communication.
BottomOfRange
The bottom of the range used for the BelowRange, WithinRange, and AboveRange events.
TopOfRange
The top of the range used for the BelowRange, WithinRange, and AboveRange events.
Unit
Specifies the unit of distance.
WithinRangeEventEnabled
Whether the WithinRange event should fire when the distance goes between the BottomOfRange and the TopOfRange.
Methods
You can set the below method blocks in the blocks section of the builder.
GetDistance
Returns the current distance in centimeters as a value between 0 and 254, or -1 if the distance can not be read.
SetCmUnit
Measure the distance in centimeters.
SetInchUnit
Measure the distance in inches.
Events
You can set the below event blocks in the blocks section of the builder.
AboveRange
Called when the detected distance has gone above the range.
BelowRange
Called when the detected distance has gone below the range.
WithinRange
Called when the detected distance has gone within the range.