|To use a keyboard to control the movement, sound and light effects of mBot, you need to use Block in the “event” area. You can switch the “space bar” to arrow keys, spacebar, letter keys, number keys and other keyboard keys.
In this example the ↑ key is used to control the movement of mBot. When you press the ↑ key, mBot moves forward.
The forward-moving rotation speed is -255~255. An active number represents moving forward, and a negative one moving back. 0 speed represents keeping still. The bigger the number is, the quicker it moves. 255 indicates 100% power of the motor. In this exmaple the speed is set first to as and then to 0 in 1 second, so as to let mBot move and then stop in 1 second.
For the glowing program, please refer to Example 1 Blink.
What if the rotation speed for moving forward is beyond 255?
If the speed is set beyond 255, it will be automatically set as 255 which is the maximum speed.
Rewrite the program. Press only one button to let mBot move, make light and sound at the same time.
Attched -mBotV1.1 Product Drawing
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.