This page describes how to Program CyberPi with mBlock 5.
-
Download and install the required software
-
Connect CyberPi to mBlock 5
-
Start to write the program
-
Upload the program to CyberPi
-
Execute the program
1. Download and install the required software
2. Connect CyberPi to mBlock 5
Before programming CyberPi, you need to connect it to mBlock 5.
Refer to the following instructions according to your mBlock 5 version:
-
Connect CyberPi to the mBlock 5 PC client
-
Connect CyberPi to mBlock 5 on the web
Connect CyberPi to the mBlock 5 PC client
(1) Use a Micro USB cable (Type-C) to connect CyberPi to your PC, and power on CyberPi.
(2) Double-click the mBlock 5 icon on your PC to open it.
(3) On the Devices tab, click + add, select CyberPi, and click OK.
(4) Click Connect to connect CyberPi to mBlock 5.
A message is displayed after CyberPi is connected, indicating that the connection is successful.
Connect CyberPi to mBlock 5 on the web
(1) Use a Micro USB cable (Type-C) to connect CyberPi to your PC, and power on CyberPi.
(2) Double-click the mLink 2 icon on your PC to open it.
(3) Click Create now in the mBlock block-based editor area to open mBlock 5 on the web.
(4) Click the Devices tab, click + add, select CyberPi, and click OK.
(5) Click Connect to connect CyberPi to mBlock 5.
A message is displayed after CyberPi is connected, indicating that the connection is successful.
3. Set the programming mode
mBlock 5 provides two programming modes, namely Live and Upload. You can click to switch the mode.
Live: In this mode, you can view the program execution effect in real-time, which facilitates the debugging of the program. In this mode, you must keep CyberPi connected to mBlock 5. If they are disconnected, the program cannot be executed.
Upload: In this mode, you need to upload the compiled program to CyberPi. After being successfully uploaded, the program can still run properly on CyberPi when it is disconnected from mBlock 5.
Now you can start to program CyberPi!
(1) Drag the blocks required to the scripts area.
a. First, define the event for triggering the play LED animation program. For example, trigger the program by pressing button B.
Tap the Events category, drag the block when button () pressed to the scripts area, and tap the drop-down list box to select button B.
b. Define the effect of playing the LED animation. For example, to play a rainbow animation.
Tap on the LED category and drag the block play LED animation()until done to the script area. Tap on the drop-down box and select rainbow.
4. Upload the program to CyberPi
Note: The program you upload will replace the last program you executed on CyberPi.Tap the Upload icon, and wait till the uploading is complete.
5. Execute the program
Press button B on CyberPi.
Tips:
-
You can change the animation effects on the blocks or add more conditions to compile your own LED animation program.
Comments
Please sign in to leave a comment.