NxtLightSensor

Last Updated On 2021-07-16

Version 1MinSDK 7Tutorial Video

A component that provides a high-level interface to a light 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 256 by default.
  • GenerateLight - it's a boolean value which is set to false by default.
  • SensorPort - it's a lego nxt sensor port value which is set to 3 by default.
  • TopOfRange - it's a non negative integer value which is set to 767 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 light level goes above the TopOfRange.


BelowRangeEventEnabled

Whether the BelowRange event should fire when the light level goes below the BottomOfRange.


BottomOfRange

The bottom of the range used for the BelowRange, WithinRange, and AboveRange events.


GenerateLight

Whether the light sensor should generate light.


TopOfRange

The top of the range used for the BelowRange, WithinRange, and AboveRange events.


WithinRangeEventEnabled

Whether the WithinRange event should fire when the light level goes between the BottomOfRange and the TopOfRange.



Methods

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

GetLightLevel

Returns the current light level as a value between 0 and 1023, or -1 if the light level can not be read.


Events

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

AboveRange

Light level has gone above the range.

BelowRange

Light level has gone below the range.

WithinRange

Light level has gone within the range.