Stage background brightness


Grade Level






Estimated duration
Longer description

Hardware requirements:

mBot/mCore Control Panel


Online debugging (serial/Bluetooth connection)

Example programs


Script description

Use the “when the green flag is clicked” block to start the program and perform online debugging.
The value of this block is the brightness of the stage background.
This block indicates the on-board light sensor values.
Add a wait time in “repeat” to avoid the background brightness change not too fast.


Knowledge points
The brightness range of the light sensor is different from that of the stage background, so it needs conversion.
Light sensor value ranges from 0 to 1000. The higher the brightness of the surrounding environment is, the larger the value is. mBlock stage background brightness ranges from -100 to 100. When the brightness changes gradually from -100 to 100, the background changes from black to pure white.
As the range of values of the light sensor is different from that of stage background, conversion is needed (the value of the light sensor/5-100) to match the light sensor values with the stage background .


Extended tasks

Task 1 Stop the sample program to replace the “brightness” in Block  with other effects, such as color, , ultra wide angle lens and then execute the program to see the effects.
Task 2 Let the light sensor to control the brightness of the panda character


Attached -mCore main control board light sensor diagram

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