Skip to content

NXT Color Sensor

Non-Visible component
Category Requires Version
LEGO® MINDSTORMS® > NXT API 21, Android 5.0 Lollipop 1

Overview

A component that provides a high-level interface to a color sensor on a LEGO MINDSTORMS NXT robot.

Events

Above Range

Light level has gone above the range. The AboveRange event will not occur if the DetectColor property is set to True or if the AboveRangeEventEnabled property is set to False.

Below Range

Light level has gone below the range. The BelowRange event will not occur if the DetectColor property is set to True or if the BelowRangeEventEnabled property is set to False.

Color Changed

Detected color has changed. The ColorChanged event will not occur if the DetectColor property is set to False or if the ColorChangedEventEnabled property is set to False.

Params
color Number

Within Range

Light level has gone within the range. The WithinRange event will not occur if the DetectColor property is set to True or if the WithinRangeEventEnabled property is set to False.

Methods

Get Color

Returns: Number

Returns the current detected color, or the color None if the color can not be read or if the DetectColor property is set to False.

Get Light Level

Returns: Number

Returns the current light level as a value between 0 and 1023, or -1 if the light level can not be read or if the DetectColor property is set to True.

Properties

Above Range Event Enabled

Boolean Default: False ➖ Read Write - Designer Blocks

Whether the AboveRange event should fire when the DetectColor property is set to False and the light level goes above the TopOfRange.

Below Range Event Enabled

Boolean Default: False ➖ Read Write - Designer Blocks

Whether the BelowRange event should fire when the DetectColor property is set to False and the light level goes below the BottomOfRange.

Bluetooth Client

Component ➖ Write - Designer

The BluetoothClient component that should be used for communication.

Bottom Of Range

Number Default: 256 ➖ Read Write - Designer Blocks

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

Color Changed Event Enabled

Boolean Default: False ➖ Read Write - Designer Blocks

Whether the ColorChanged event should fire when the DetectColor property is set to True and the detected color changes.

Detect Color

Boolean Default: True ➖ Read Write - Designer Blocks

Whether the sensor should detect color or light. True indicates that the sensor should detect color; False indicates that the sensor should detect light. If the DetectColor property is set to True, the BelowRange, WithinRange, and AboveRange events will not occur and the sensor will not generate color. If the DetectColor property is set to False, the ColorChanged event will not occur.

Generate Color

Number Default: #FFFFFF00  ➖ Read Write - Designer Blocks

The color that should generated by the sensor. Only None, Red, Green, or Blue are valid values. The sensor will not generate color when the DetectColor property is set to True.

Sensor Port

Text Default: 3 ➖ Write - Designer

The sensor port that the sensor is connected to.

Top Of Range

Number Default: 767 ➖ Read Write - Designer Blocks

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

Within Range Event Enabled

Boolean Default: False ➖ Read Write - Designer Blocks

Whether the WithinRange event should fire when the DetectColor property is set to False and the light level goes between the BottomOfRange and the TopOfRange.


Last update: November 9, 2022