

LOWER SECONDARY

COMPUTER SCIENCE

mBot

40MINS
Hardware requirements:
mBot/mCore Control Panel
Implementation:
Online debugging (serial/Bluetooth connection)
Example programs
Script description
In this case light sensor, for example, explains how to capture sensor values and display them in real time. Other sensors use the same method to collect data.
As it involves the stage show, it is necessary to use a Usb cable to connect the computer with the control board via a serial port rather than burning the program to the Arduino board.
![]() |
Use the “when the green flag is clicked” block to start the program and perform online debugging. |
![]() |
Use ![]() |
![]() |
By repeating, to allow the values of the light sensor be displayed continually. |
Knowledge points
Point 1 Introduction of Light Sensor
Sensors are used to detect events or changes in the environment and send information to the electronic components of other electronic devices. While the program is running and debugging, it is often required to collect real-time sensor values to help us understand the environment light, sound, distance and other information.
Light sensor value range: 0~1000, exposed under sunshine (> 500), evening (0 ~ 100), lighting (100 to 500).
Point 2 What if it is not repeated? blocks can ensure the light sensor display real-time values, or only the start-up values are displayed continually.
Also, if the ambient light is not stable (e. g. fluorescent lamp), you can see the rapid change of sensor values (the script is running fast and the values vary with the ambient light in real time). Now block can be added to reduce the speed of value changing and you can see it clearly.
Attached -mCore main control board light sensor diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.