1. [DIRECTION] at [POWER]RPM for [TIME] secs

mBot2 Shield - 图1

Makes mBot2 move forward, move backward, turn left, or turn right at the specified speed for the specified period

How to use

Click to select a motion option from the drop-down list box and set the speed and time.

Example

image.png

After you press the space key, mBot2 moves forward for two seconds.


2. [DIRECTION] at [POWER] RPM

mBot2 Shield - 图3

Makes mBot2 move forward, move backward, turn left, or turn right at the specified speed

How to use

Click to select a motion option from the drop-down list box and set the speed.

Example

image.png

After you press the space key, mBot2 keeps moving forward.


3. [DIRECTION] [POWER] [fieldMenu_3] until done

mblock_block_1626074021823.png

Makes mBot2 move forward or backward the specified distance

How to use

Click to select a motion option from the drop-down list box and set the distance.
The subsequent block(s) is not executed until the execution of this block is complete.

Example

image.png

After you press the space key, mBot2 moves forward 20 cm and then the screen of CyberPi displays “Arrived!”


4. [fieldMenu_1] [ANGLE]° until done

mBot2 Shield - 图7

Makes mBot2 turn left or right the specified degrees

How to use

Click to select a direction from the drop-down list box and set the number of degrees.
The subsequent block(s) is not executed until the execution of this block is complete.

Example

image.png

Use the arrow keys and space key to control the motion of mBot2.


5. encoder motor [fieldMenu_1] [image_2] rotates at [LEFT_POWER][fieldMenu_4] for [number_3] secs

mBot2 Shield - 图9

Makes the specified wheel of mBot2 rotate at the specified speed or power for the specified time

How to use

Setting range of the power: –100 to +100; A positive value indicates that the output shaft of the encoder motor rotates counterclockwise; and a negative one indicates that the output shaft of the encoder motor rotates clockwise.
Setting range of the speed: –200 to +200; A positive value indicates that the output shaft of the encoder motor rotates counterclockwise; and a negative one indicates that the output shaft of the encoder motor rotates clockwise.

mBot2 Shield - 图10

Click to select a wheel from the drop-down list box, specify the power or speed, and set the time.

Example

image.png

When you press the right arrow key, the left wheel of mBot2 rotates to the right for 0.5 seconds.


6. encoder motor [inputMenu_1] [image_2] rotates at [LEFT_POWER][fieldMenu_4]

mBot2 Shield - 图12

Makes the specified wheel of mBot2 rotate at the specified speed or power

How to use

Setting range of the power: –100 to +100; A positive value indicates that the output shaft of the encoder motor rotates counterclockwise; and a negative one indicates that the output shaft of the encoder motor rotates clockwise.
Setting range of the speed: –200 to +200; A positive value indicates that the output shaft of the encoder motor rotates counterclockwise; and a negative one indicates that the output shaft of the encoder motor rotates clockwise.

Click to select a wheel from the drop-down list box and set the power or speed.

Example

image.png
When you press the right arrow key, the left wheel of mBot2 keeps rotating to the right.


7. encoder motor [fieldMenu_1] [image_1] rotates by [LEFT_POWER] °

mblock_block_1626074289995.png

Makes the specified encoder motor of mBot2 rotate the specified degrees

How to use

Click to select a motor from the drop-down list box and set the number of degrees.
When you set the number of degrees to a positive value, the output shaft of the encoder motor rotates counterclockwise; and when you set it to a negative value, the output shaft of the encoder motor rotates clockwise.

Example

image.png
When you press the right arrow key, the left wheel of mBot2 turns right.


8. encoder motor EM1 [image_1] rotates at [LEFT_POWER]RPM, encoder motor EM2 [image_3] rotates at [number_2]RPM

mblock_block_1626074333907.png

Makes the two encoder motors of mBot2 rotate at the specified speed

How to use

Click to set the speed of each encoder motor.
Setting range of the speed: –200 to +200 (RPM)
When you set the speed to a positive value, the output shaft of the encoder motor rotates counterclockwise; and when you set it to a negative one, the output shaft of the encoder motor rotates clockwise.

Example

image.png

When you press the right arrow key, mBot2 moves forward.


9. encoder motor EM1 [image_1] rotates at [LEFT_POWER] % power, encoder motor EM2 [image_3] rotates at [number_2] % power

mBot2 Shield - 图18

Makes the two encoder motors of mBot2 rotate at the specified power

How to use

Click to set the power of each encoder motor.
Setting range of the power: –100 to +100 (%)
When you set the power to a positive value, the output shaft of the encoder motor rotates counterclockwise; and when you set it to a negative one, the output shaft of the encoder motor rotates clockwise.

Example

image.png
When you press the right arrow key, mBot2 turns right at the specified power.


10. stop encoder motor[fieldMenu_1]

mblock_block_1626074415976.png

Stops the specified encoder motor(s) of mBot2

How to use

Click to select an encoder motor or both the encoder motors.

Example

mBot2 Shield - 图21

When you press the right arrow key, mBot2 turns right at the specified power.
When you press the s key, mBot2 stops moving.


11. encoder motor [inputMenu_1] [fieldMenu_2] autolock

mblock_block_1626074513376.png

Enables or disables the autolock function of the specified encoder motor(s)

How to use

After you enable the autolock function for an encoder motor, the encoder motor attempts to remain in the original position after mBot2 stops moving.
The autolock function is disabled by default.
Click to select an encoder motor or both the encoder motors from the drop-down list box.

Example

image.png

When you press the up arrow key, mBot2 moves forward; and when you press the s key, mBot2 stops moving.


12. encoder motor[inputMenu_2]’s [image_2][fieldMenu_3]

mblock_block_1626075781245.png

Reports the speed or power of the specified encoder motor

How to use

Click to select an motor and the speed or power.
Value range of the rotational speed: –200 to +200 (RPM)
Value range of the power: –100 to +100 (%)
You can select the check box on the left of this block to view the speed or power of the motor on the stage.

Note: This is a reporter block that must be used in combination with another block requiring data.

Example

image.png
When you press the up arrow key, mBot2 moves forward; and when you press the d key, the display on CyberPi displays the rotational speed of the left encoder motor.


13. encoder motor[inputMenu_1] [image_2] rotated angle (°)

mblock_block_1626075864002.png

Reports the number of degrees the specified encoder motor rotates

How to use

mBot2 resets the number of degrees its encoder motors have rotated when being powered on.
The number of degrees increases when the encoder motor rotates counterclockwise; and it decreases when the encoder motor rotates clockwise.
Click to select an encoder motor from the drop-down list box.

Example

image.png

After you press the d key, the display on CyberPi displays the number of degrees the left encoder motor rotates in real time. When you press the right arrow key, the number increases; and when you press the left arrow key, the number decreases.


14. reset encoder motor [inputMenu_1][image_2] rotated angle

mblock_block_1626075886740.png

Resets the number of degrees the specified encoder motor(s) rotates

How to use

Click to select an encoder motor or encoder motors from the drop-down list box.

Example

image.png

After you press the d key, the display on CyberPi displays the number of degrees the left encoder motor rotates in real time. When you press the right arrow key, the number increases; when you press the left arrow key, the number decreases; and when you press the r key, the number is reset to zero.


15. motor [fieldMenu_1] rotates at [number_2]% power

mblock_block_1626076136932.png

Provides the specified power at the specified motor port

How to use

mBot2 provides two DC motor ports, M1 and M2.

mBot2 Shield - 图31

Setting range of the power: –100 to +100 (%)
When you set the power to a positive value, the output shaft of the motor rotates counterclockwise; and when you set it to a negative one, the output shaft of the motor rotates clockwise.
Click to select a motor port or both the motor ports.

Example

Use two DC motors and wheels to build a movable structure, connect the left motor to port M1, and connect the right motor to port M2.
image.png
When you press the up arrow key, the structure moves forward; when you press the right arrow key, it turns right; when you press the left arrow key, it turns left; and when you press the down arrow key, it moves backward.


16. motor [fieldMenu_1] rotates with power up [power]%

mblock_block_1626076122231.png

Increases the power at the specified port by the specified amount

How to use

Click to select a motor port or both the motor ports from the drop-down list box and set the amount by which the power is to be increased.
Setting range of the power: –200 to +200 (%)

Example

Use two DC motors and wheels to build a movable structure, connect the left motor to port M1, and connect the right motor to port M2.

image.png

When you press the space key, the structure moves forward; and when you press the up arrow key, the structure accelerates forward.


17. set motor M1 power to [number_1]% , motor M2 power to [number_2]%

mBot2 Shield - 图35

Provides the specified power at the two motor ports

How to use

Click to set the power at each motor port.
Setting range of the power: –100 to +100 (%)

Example

Use two DC motors and wheels to build a movable structure, connect the left motor to port M1, and connect the right motor to port M2.
image.png
When you press the up arrow key, the structure moves forward.


18. motor [fieldMenu_1] rotation output power(%)

mblock_block_1626076243144.png

Reports the output power of the specified motor port

How to use

Click to select a motor port from the drop-down list box.
Value range of the power: –100 to +100 (%)

Note: This is a reporter block that must be used in combination with another block requiring data.

Example

Use two DC motors and wheels to build a movable structure, connect the left motor to port M1, and connect the right motor to port M2.
image.png
When you press the up arrow key, the structure moves forward; and when you press the d key, the display on CyberPi displays the output power of motor port M1 in real time.


19. stop motor [fieldMenu_1]

mblock_block_1626076305069.png

Stops the power output of the specified motor port

How to use

Click to select a motor port or both the motor ports from the drop-down list box.

Example

Use two DC motors and wheels to build a movable structure, connect the left motor to port M1, and connect the right motor to port M2.

image.png

When you press the up arrow key, the structure moves forward; and when you press the s key, the structure stops moving.


20. set servo [fieldMenu_1] angle to [angle]°

mblock_block_1626076363014.png

Rotates the output shaft(s) of the servo(s) connected to the specified port(s) to the specified number of degrees

How to use

mBot2 provides two multi-function ports and two servo ports, and the multi-function ports can serve as servo ports.

image.png

Click to select a port from the drop-down list box and set the number of degrees.
Setting range of the degrees: 0–180 (degrees)

Example

image.png
When you press the space key, all the output shafts of the servos connected to mBot2 rotate to the position of 90 degrees.


21. increase servo [fieldMenu_1] angle by [angle]°

mblock_block_1626076379474.png

Changes the number of degrees the output shaft(s) of the servo(s) connected to the specified port(s) rotates by the specified amount

How to use

If you haven’t set the degrees of the output shaft of a servo, when this block is executed, the output shaft rotates to the position of 20 degrees by default before rotating the added degrees.
Click to select a port or all the ports from the drop-down list box and set the number of degrees.
Setting range of the degrees: –180 to +180 (degrees)

Example

image.png
When you press the space key, all the output shafts of the servos connected to mBot2 rotate 10 degrees from the original positions.


22. set servo angle S1 [number_1]° , S2 [number_2]° , S3 [number_3]°, S4 [number_4]°

mBot2 Shield - 图46

Rotates the output shafts of the servos to the specified number of degrees separately

How to use

Click to set the number of degrees for the output shaft of the servo connected to each servo port.
Setting range of the degrees: 0–180 (degrees)

Example

image.png

When you press the space key, the output shafts of the servos connected to mBot2 rotate to the specified positions separately.


23. servo [fieldMenu_1] current angle (°)

mblock_block_1626076437157.png

Reports the number of degrees of the position to which the output shaft of the servo connected to the specified port rotates

How to use

Click to select a port from the drop-down list box.
This is a reporter block that must be used in combination with another block requiring data.

Example

image.png

When you press the space key, the display on CyberPi displays the degrees of the position to which the output shaft of the servo connected to port S1 rotates.


24. servo [fieldMenu_1] release angle

mblock_block_1626076455941.png

Releases the output shaft(s) of the servo(s) connected to the specified port(s)

How to use

Click to select a port or all the ports from the drop-down list box.
After the output shaft of a servo is released, you can manually rotate the output shaft of the servo.

Example

image.png

After you press the space key, the output shaft of the servo connected to port S1 rotates to the position of 90 degrees, and you can manually rotate the output shaft in one second.


25. servo [fieldMenu_1] back to zero position

mblock_block_1626076491678.png

Rotates the output shaft(s) of the servo(s) connected to the specified port(s) to the zero-degree position

How to use

Click to select a port or all the ports from the drop-down list box.

Example

image.png

When you press the space key, the output shafts of all the servos connected to mBot2 rotate to the zero-degree position.


26. LED strip [fieldMenu_1] lights up [facePanel]

mblock_block_1626076616958.png

Lights up the LEDs on the LED strip connected to the specified port in the specified color(s)

How to use

mBot2 provides two multi-function ports, S1 and S2, that can drive LED strips, supporting a maximum of 36 LEDs.
If you set color(s) for more than 36 LEDs, only the colors of the first 36 LEDs take effect.
image.png

Click to select a port or all the ports from the drop-down list box, and click to set the color(s) of the LEDs.

Example

image.png

When you press the space key, the LED strip connected to port S1 is lit up in the specified colors.


27. LED strip [fieldMenu_1] LED [fieldMenu_2] displays color [color_1]

mblock_block_1626076647019.png

Lights up the specified LED(s) on the LED strip(s) connected to the specified port(s) in the specified color

How to use

Click to select a port or all the ports and select an LED or all the LEDs from the drop-down list boxes, and click to set the color.

Example

image.png

When you press the space key, the first LED on the LED strip connected to port S1 is lit up in red, and the second LED is lit up in blue in one second.


28. LED strip [fieldMenu_1] LED [fieldMenu_2] displays R: [r] G: [g] B: [b]

mblock_block_1626076660946.png

Lights up the specified LED(s) on the LED strip(s) connected to the specified port(s) in the color that is the combination of the specified intensity of red, green, and blue

How to use

Click to select a port or all the ports and select an LED or all the LEDs from the drop-down list boxes, and click to set the color value.
R: red
G: green
B: blue
Setting range of the color values: 0–255

Example

image.png

When you press the space key, the first LED on the LED strip connected to port S1 is lit up in red, and the second LED is lit up in green in one second.


29. LED strip [fieldMenu_1] rolls [number_2] LEDs with cycle [number_3]

mblock_block_1626076695570.png

Makes the colors of the LEDs on the LED strip connected to the specified port roll from left to right by the specified number of positions in the specified range

How to use

Click to select a port or all the ports from the drop-down list box and set the number of positions and range.

Example

A 12-LED strip is used.
image.png

When you press the space key, the LED strip is lit up as follows.

mBot2 Shield - 图63

The colors of the LEDs roll from left to right as follows in one second.
image.png


30. LED strip [fieldMenu_1] LED [fieldMenu_2] lights off

mblock_block_1626076804956.png

Turns off the specified LED(s) on the LED strip(s) connected to the specified port(s)

How to use

Click to select a port or all the ports and select an LED or all the LEDs from the drop-down list box.

Example

image.png
After you press the space key, the first LED on the LED strip connected to port S1 is turned on and off alternately.


31. increase LED strip [fieldMenu_1] brightness by [number_1] %

mblock_block_1626076864986.png

Changes the brightness of the LED strip connected to the specified port

How to use

Click to select a port or all the ports from the drop-down list box, and set the amount by which the brightness is to be changed.
Setting range of the amount:–100 to +100 (%)
A positive value indicates that the brightness is to be increased, and a negative one indicates that the brightness is to be reduced.

Example

A 12-LED strip is used.
image.png

When you press the space key, the LED strip connected to port S1 is lit up in the specified colors. Then, you can press the up and down arrow keys to change the brightness of the LED strip.


32. set LED strip [fieldMenu_1] brightness to [number_1]%

mblock_block_1626076897021.png

Sets the brightness of the LED strip connected to the specified port

How to use

Click to select a port or all the ports from the drop-down list box and set the brightness.
Setting range of the brightness: 0–100 (%)

Example

mBot2 Shield - 图70

When you press the space key, the brightness of the LED strip connected to port S1 is set to 50%.


33. LED strip [fieldMenu_1] brightness(%)

mblock_block_1626076915944.png

Reports the brightness of the LED strip connected to the specified port

How to use

Click to select a port from the drop-down list box.
This is a reporter block that must be used in combination with another block requiring data.

Example

A 12-LED strip is used.

image.png

When you press the space key, the LED strip connected to port S1 is lit up in the specified colors. Then, you can press the up and down arrow keys to change the brightness of the LED strip. After you press the d key, you can see the brightness of the LED strip on the display of CyberPi in real time.


34. pin [pin_number] on high level?

mblock_block_1626076969302.png

Determines whether the specified pin is in the high-level state

How to use

Click to select a pin from the drop-down list box.

This is a Boolean block that contains a condition. Use it in combination with another block that requires a condition.

Example

image.png

After you press the space key, the LEDs on CyberPi are lit up in green if pin S1 is in the high-level state and in red if it is in the low-level state.


35. digital read pin [pin_number]

mblock_block_1626076981451.png

Reports the digital input of the specified pin

How to use

Click to select a pin.

Digital input range: 0 or 1
0: low level; 1: high level

This is a reporter block that must be used in combination with another block requiring data.

Example

image.png
After you press the d key, you can view the digital input of pin S1 on the display of CyberPi in real time.


36. voltage read pin inputMenu_1

mblock_block_1626077045037.png

Reports the voltage at the specified pin

How to use

Click to select a pin.

Voltage value range: 0–5 V

This is a reporter block that must be used in combination with another block requiring data.

Example

image.png

After you press the d key, you can view the voltage at pin S1 on the display of CyberPi in real time.


37. digital write [Digtial_value] to pin [fieldMenu_1]

mblock_block_1626077061684.png

Sets the specified digital input for the specified pin(s)

How to use

Click to select a pin or both ports and set the digital input.

Setting range of the digital input: 0 or 1; any non-zero value is processed as 1

Example

image.png
When you press the space key, the digital input of pin S1 is set to 1.


38. analog write to pin[pin_number], duty cycle[PWM_value]%, frequency [fieldMenu_3]Hz

mblock_block_1626077118334.png

Sets the specified pin(s) to output PWM signals with the specified duty cycle and frequency

How to use

What is PWM?

Pulse-width modulation (PWM) is technology for performing digital encoding on analog signals. It involves two key parameters, namely frequency and duty cycle. The frequency determines the time required for completing a single cycle and the rate at which signals change from high to low level. The duty cycle determines the time the signals stay in high level within the total period of time. By changing the duty cycle of PWM, you can change the average voltage of the output signals, and thus provide analog voltage output.

Click to select a pin or both pins from the drop-down list box and set the duty cycle and frequency.

Setting range of the duty cycle: 0–100%

Setting range of the frequency: 1–2000 Hz

Example

mBot2 Shield - 图82

When you press the space key, all the pins output PWM signals with the duty cycle of 50% and frequency of 2000 Hz.