NxtUltrasonicSensor

Last Updated On 2021-07-16

Version 1MinSDK 7Tutorial Video

A component that provides a high-level interface to an ultrasonic sensor on a LEGO MINDSTORMS NXT 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 nxt sensor port value which is set to 4 by default.
  • TopOfRange - it's a non negative integer value which is set to 90 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.


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.


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.


Events

You can set the below event blocks in the blocks section of the builder.

AboveRange

Distance has gone above the range.

BelowRange

Distance has gone below the range.

WithinRange

Distance has gone within the range.