

LOWER SECONDARY

COMPUTER SCIENCE

mBot

40MINS
Hardware requirements:
mBot/mCore Control Panel
Implementation:
Upload the program to Arduino
Example programs
Script description
![]() |
Define the on-board button state (for onboard button see the attached photo) |
![]() |
Define the tone and rhythms of the buzzer. |
![]() |
When the program is running, judge whether the sound playing task is executed according to the status of the onboard button. The block indicates that ![]() ![]() |
![]() |
Repeat it to ensure each pressing makes sound. |
Knowledge points
Point 1 Condition judge the logic of Block
In our life, people need to choose or carry out different tasks according to conditions, such as wearing T shirts in hot weather or padded clothes in cold weather. Here the air temperature is a condition. Whether you wear a T shirt or padded clothes depends on the judgment of the air temperature. For a robot, it turns before a barrier or moves forward if there is no barrier in front. Whether there is a barrier is a condition and whether to turn or move forward is the executed result after judgment.
In ,if Condition
is true, execute the block script within. In this example, the condition is “whether the onboard button is pressed”; when it is true, the onboard buzzer sounds a tone and when it is not true, nothing is done.
Point 2 What if I do not use ?
As the status of the onboard button is judged all the time when the program is running, you need to use the “repeat” block. If you do not use “repeat”, the program, when started, will do judgement once quickly and then it will cease to run, and then pressing the button will not control the buzzer.
Attached -mCore main control board buzzer and onboard button diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.