1. color sensor [PORT] [COLOR] value

Color Sensor - 图1

Reports the value of the specified color detected by the color sensor connected to the specified port

How to Use

A color sensor can detect the values of the colors red, green, and blue. In this block, R refers to red, G refers to green, and B refers to blue.
Value range of red, green, and blue: 0–255
This block provides 12 port options. Click to select the one to which the color sensor is connected.
Note: This is a reporter block that must be used in combiantion with another block requiring data.

Example

Color Sensor - 图2
Note: Ensure that you have connected a display panel to mBot through port 1 and a color sensor through port 2, and uploaded the program to mBot.
When you start mBot, the display panel displays the value of red detected by the color sensor.


2. color sensor[PORT]detects[COLOR]

Color Sensor - 图3

Determines whether the color sensor connected to the specified port detects the specified color

How to Use

A color sensor can detect six colors, namely white, red, yellow, green, blue, black. Click to select one.
This block provides 12 port options. Click to select the one to which the color sensor is connected.
Note: This is a Boolean block that contains a condition. Use it in combination with another block that requires a condition.

Example

Color Sensor - 图4
Note: Ensure that you have connected a color sensor to mBot through port 1 and uploaded the program to mBot.
After you start mBot, it moves forward, and if the color sensor detects the color white, it turns right.


3. color sensor[PORT] set fill light LED to [STATE]

Color Sensor - 图5

Turns on or off the LED fill light of the color sensor connected to the specified port

How to Use

This block provides 12 port options. Click to select the one to which the color sensor is connected.

Example

Color Sensor - 图6
Note: Ensure that you have connected a color sensor to mBot through port 1.
When you start mBot, the LED fill light is turned on if the color sensor detects the color black, otherwise, it is turned off.