Hardware requirements:

mBot/mCore Control Panel


Upload the program to Arduino

Effect demo


Example programs


Script description

Using the “All/Left/Right” options to choose the LED light.
Figures represent the brightness; the larger the figure is, the more brightness it represents (range 0~255).
When the color parameters are 0, the LED light is off. Use this block to keep LED light off.
Different time can be set to control the blink frequency of the LED light.
Repeat the contained script to control the blink frequency.


Knowledge points

Point 1 Why use the block  to reset the LED?
The two onboard LEDs are individually controlled, and in the current mode it will stay constant (for example, if you make the left LED light up, it will remain constantly lit). If you carry out the script to light up the right-side LED, it will not change the state of the left-side LED, but you will see that both LEDs will stay continuously lit. Therefore, in order to achieve the alternating flashing effect for the LEDs on both sides, you should first add the script to turn off the left side LED before the right-side LED is turned on. Similarly, you should also turn off the right-side LED before the left-side LED is turned on. In the example script, use the block  to turn off all LEDs on board, and you can compare it to the following scripts and their effects.

Script Effects (please upload the program to Arduino)
 (Delete the block  from the example script) The LEDs on each side continuously light, without a noticeable alternating-flashing effect (the lit-up LEDs will not be off).

(Replace the block  from the example script)

The effect is identical to that in the example script.


Point 2 If you switch the positions of the block for lighting and turning off the lights, what will happen?
Now, the block are switched as shown in the picture below (the light turns on and then turns off, then waits for 1 second). Due to the fact that the light-up program does not have continuous time, you can only observe the brief flash, and the onboard LED remains largely turned off. This process is unable to achieve the alternating color flash effect.


Extended tasks
Change the example script to keep the color of the onboard LED light blinking between red and blue. (you need to upload the program to the Arduino)



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.