Under Scratch mode which is defualt mode when mBlock start, mBlock could program robot through USB serial port, the robot is running a program could communicate with mBlock, and robot could intercate with Stage and create more insteresting projects and animations.
If you havn’t installed Scratch yet, visit here.
In this example, we want to turn on an LED whenever you press Space in your keyboard. There is a programmable LED in evive which is connected to the digital pin 13. Hence, whenever the pin 13 is HIGH the LED glows and whenever the pin 13 is LOW it turns off.
We will be continuously checking if the Space key is pressed. This will be either true or false. Now, we will use conditional statements, which will take decision to execute particular statements according to the result. In our case, this is if-else, where if the result is true, LED will be ON, else LED will be OFF.
The next step is to express your logic in a way so that the computer can understand it. This is easy if one uses Scratch since it has built in blocks for basic functions and one does not have to write stuff every time. For e.g. there is a block named ‘when flag is pressed’, which starts the execution of the program when flag above stage is pressed which can be used to start our program:
Your program is ready now and you can press ‘space’ to start it. The whole script will start glowing indicating that the program is running. To stop it press ‘Esc’ on keyboard.