1. initialize RGB line follower [SENSOR_ID] : at [PORT]

RGB Line Follower - 图1

Defines the serial number of the RGB line follower connected to the specified port of mBot

How to Use

You need to use this block to define an RGB line follower before programming it.
This block provides 12 port options, and 4 serial numbers. Click to select a port and serial number to map them. The serial number of an RGB line follower is unique.
Note: This block is available only in the Upload mode.

Example

RGB Line Follower - 图2
Note: Ensure that you have connected an RGB line follower to mBot through port 3 and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1.


2. RGB line follower[SENSOR_ID] : (default line following) set turning sensitivity to [SENS]

RGB Line Follower - 图3

Sets the turning sensitivity of the specified RGB line follower

How to Use

This block is available only in the default line folllowing method. For other line following methods, visit http://docs.makeblock.com/diy-platform/en/electronic-modules/sensors/rgb-line-follower.html.
You need to define an RGB line follower before using this block. Click to select a defined RGB line follower.
The turning sensitivity is used to modify the line following response speed. A greater value indicates higher sensitivity during turning. Click to set the turning sensitivity.
Setting range: 0–1
Note: This block is available only in the Upload mode.

Example

RGB Line Follower - 图4
Note: Ensure that you have connected an RGB line follower to mBot through port 3 and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1 and its turning sensitivity is set to 0.3.


3. RGB line follower[SENSOR_ID]: (default line following) motor differential speed

RGB Line Follower - 图5

Reports the motor differential speed of the specified RGB line follower

How to Use

This block is available only in the default line folllowing method. For other line following methods, visit http://docs.makeblock.com/diy-platform/en/electronic-modules/sensors/rgb-line-follower.html.
You need to define an RGB line follower before using this block. Click to select a defined RGB line follower.
This block is used to obtain the offset of the RGB line follower from the track.
Range of the motor differential speed: –512 to +512
A positive value indicates that the line is biased to RGB4, and a greater value indicates a larger bias; a negative value indicates that the line is biased to RGB1, and a greater absolute value indicates a larger bias.
RGB Line Follower - 图6
In other words, when the RGB line follower is installed with the sensors facing forward, a positive offset indicates that the RGB line follower is biased to the left of the line, and a negative offset indicates that it is biased to the right of the line.
Note: This block is available only in the Upload mode. This is a reporter block that must be used in combiantion with another block requiring data.

Example

RGB Line Follower - 图7
Note: Ensure that you have connected an RGB line follower to mBot through port 3 and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1. Two seconds later, mBot moves forward at the power of 50%, and the display panel displays the motor differential speed of RGB line follower 1.


4. RGB line follower [SENSOR_ID]: probe status as (RGB4~RGB1) [SENSOR_STATUS]

RGB Line Follower - 图8

Determines whether the sensors of the specified RGB line follower are in the specified state

How to Use

You need to define an RGB line follower before using this block. Click to select a defined RGB line follower.
As shown in the following figure, an RGB line follower is equipped with 4 sensors, namely RGB4, RGB3, RGB2, and RGB1 from left to right.
RGB Line Follower - 图9
The state value 1 indicates that the corresponding sensor detects the background, and the corresponding LED is lit up; while the state value 0 indicates that the corresponding sensor detects the line, and the corresponding LED is not lit up.
For example, 0100 indicates that the sensors, RGB4, RGB3, RGB2, and RGB1, detect the line, background, line, and line respectively; and the LEDs are off, on, off, and off, respectively.
Note: This block is available only in the Upload mode. This is a Boolean block that contains a condition. Whether the condition is met determines the execution of the subsequent blocks. A Boolean block must be used in combination with another block that requires a condition. It cannot be used independently.

Example

RGB Line Follower - 图10
Note: Ensure that you have connected an RGB line follower to mBot through port 3 and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1. Two seconds later, mBot moves forward at the power of 50%. If all the sensors of RGB line follower 1 detect the background, that is, the state value is 1111, mBot stops moving.


5. RGB line follower [SENSOR_ID]: probe[CHANNEL] detects background color?

RGB Line Follower - 图11

Determines whether the specified sensor of the specified RGB line follower detects the background color

How to Use

You need to define an RGB line follower before using this block. Click to select a defined RGB line follower.
As shown in the following figure, an RGB line follower is equipped with 4 sensors, namely RGB4, RGB3, RGB2, and RGB1 from left to right.
RGB Line Follower - 图12
Note: This block is available only in the Upload mode. This is a Boolean block that contains a condition. Use it in combination with another block that requires a condition.

Example

RGB Line Follower - 图13
Note: Ensure that you have connected an RGB line follower to mBot through port 3 and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1. Two seconds later, mBot moves forward at the power of 50%. If RGB1 of RGB line follower 1 detect the background color, mBot stops moving.


6. RGB line follower [SENSOR_ID]: set target color and fill light to [COLOR]

RGB Line Follower - 图14

Sets the fill light color of the specified RGB line follower

How to Use

You need to define an RGB line follower before using this block. Click to select a defined RGB line follower.
RGB line followers support three colors, namely red, green, and blue. Click to select one.
Note: This block is available only in the Upload mode.

Example

RGB Line Follower - 图15
Note: Ensure that you have connected an RGB line follower to mBot through port 3 and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1, and the color to which it is sensitive, that is, the color of the fill light, is set to red.


7. RGB line follower [SENSOR_ID] : probe[CHANNEL] return value

RGB Line Follower - 图16

Reports the value of the color detected by the specified sensor of the specified RGB line follower

How to Use

You need to define an RGB line follower before using this block. Click to select a defined RGB line follower.
Range of the color value: 0–255, a smaller value indicates that the color approaches black, and a greater value indicates that the color approaches white, as shown in the following figure.
RGB Line Follower - 图17
As shown in the following figure, an RGB line follower is equipped with 4 sensors, namely RGB4, RGB3, RGB2, and RGB1 from left to right.
RGB Line Follower - 图18
Note: This block is available only in the Upload mode. This is a reporter block that must be used in combiantion with another block requiring data.

Example

RGB Line Follower - 图19
Note: Ensure that you have connected a display panel to mBot through port 1 and an RGB line follower through port 3, and uploaded the program to mBot.
When you start mBot, the RGB line follower is defined as RGB line follower 1. Two seconds later, the display panel displays the value of the color detected by RGB1 of RGB line follower 1.