0% found this document useful (0 votes)
36 views

5.Programming Software.pdf

The document provides a comprehensive guide on programming CyberPi series products using mBlock 5, which includes a block-based graphical editor and a Python editor. It covers how to obtain mBlock 5, connect devices via USB or Bluetooth, and utilize features such as the Device Library and Extension Center, as well as programming modes like Live and Upload. Additionally, it explains how to interact with sprites and use various programming languages supported by mBlock 5.

Uploaded by

ganeshkabrahnl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

5.Programming Software.pdf

The document provides a comprehensive guide on programming CyberPi series products using mBlock 5, which includes a block-based graphical editor and a Python editor. It covers how to obtain mBlock 5, connect devices via USB or Bluetooth, and utilize features such as the Device Library and Extension Center, as well as programming modes like Live and Upload. Additionally, it explains how to interact with sprites and use various programming languages supported by mBlock 5.

Uploaded by

ganeshkabrahnl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Programming Software

CyberPi series products can be programmed with mBlock 5 which provides a block-based graphical editor (the default
editor, referred to as mBlock 5) and Python editor (referred to as mBlock-Python Editor).

mBlock 5
Obtaining mBlock 5
1. Visit the mBlock website.

2. Select the version applicable to your device. For example, if you use a PC, you can download the version for PCs
or use mBlock 5 on the web. For details, see Obtain and Install mBlock 5.

Learning how to use mBlock 5


Before using mBlock 5 to program CyberPi series products, you need to know about some basic operations.

Connect Devices
Device Library and Extension Center
Live and Upload Modes
Programming Languages
Interact with Sprites

For more information and help about mBlock 5, see mBlock Block-Based Editor.

Block help
mBlock 5 provides multiple types of blocks for CyberPi series products, and you can right-click a block to see the help
for it.

mBlock-Python Editor
Open mBlock-Python Editor
Way 1
You can click the editor switching button on the upper-right of mBlock 5 on the web to go to mBlock-Python Editor.
Way 2
Open mBlock-Python Editor by entering its URL address: https://python.mblock.cc

For more information, see “Open mBlock-Python Editor.”

Python API
Python API Documentations
The Python library cyberpi is provided for CyberPi series products. For details, see “Python API Documentation for
CyberPi.”

Quick access to the Python API Documentation for CyberPi


On mBlock-Python Editor, click Tutorials on the toolbar, and then click Python API Documentation for CyberPi in
the title list.
Connect Devices
Connect Devices
mBlock 5 supports a wide range of devices, not only those produced by Makeblock, but also those by other
manufacturers. You can connect most of the devices to mBlock 5 by following the built-in user guide. For devices of
some brands, you may need to follow the instructions in the corresponding user manuals to connect them.

Connect Devices to mBlock 5


mBlock 5 supports two ways of connecting devices: (1) Through USB; and (2) Through Bluetooth 4.0

Note:

mBlock 5 can be connected to only one device at a time. When a new device is connected, the previously connected
one is disconnected. For the specific connection way of a device, see the connection interface.

Way 1: Through USB


1. Connect the device to a computer.
You can connect the device directly to the computer by using a USB data cable, or use the Makeblock Bluetooth
dongle to implement wireless USB connection.

Connection through USB data cable


(1) Use the USB data cable included in the package to connect the device to the computer.

Refer to the device guide. Ensure that the device is successfully connected.

(2) Turn on the device.

Connection through Makeblock Bluetooth dongle


The Makeblock Bluetooth dongle is designed for Makeblock products. It can implement USB connection without a
USB data cable.

(1) Connect the Bluetooth dongle to a USB port of the computer.

(2) Press the button on the Bluetooth dongle.

When the indicator blinks fast, the Bluetooth dongle is searching for a device.

(3) Turn on the device that is to be connected and place it close to the Bluetooth dongle.

The device and Bluetooth dongle are automatically paired. After the pairing is completed, the indicator on the
Bluetooth dongle is normally on.

2. Open mBlock 5 and add your device from the device library.
2
3. Click “Connect” to connect your device.

4. In the dialog box that appears, click the “USB” tab, use the serial port
automatically identified by mBlock 5, and click “Connect”.
Note:

If multiple devices are connected to the computer, choose the serial port for the device to be connected from the drop-
down list box. To display all available devices, select Show all connectable devices.

After the device is connected, “Device connected” is displayed

2
Way 2: Through Bluetooth 4.0
You can use connect the device to a computer through Bluetooth 4.0.

Supported Bluetooth versions: Bluetooth 4.0, 4.1, and 4.2; Bluetooth 2.0 and 5.0 not supported

Supported devices: mBot and mBot Ranger

Supported functions: Bluetooth 4.0-based connection supports only the Live mode of mBlock 5. You cannot upload
programs to the device through Bluetooth 4.0.

System requirements:

Windows: The built-in Bluetooth protocol is Bluetooth 4.0. If the protocol version is not 4.0, it is recommended
that you use a Bluetooth 4.0 dongle. (For detailed instructions, see Windows Bluetooth 4.0 User Guide.)
Mac OS: Most of the models are supported.

To check the Bluetooth version of a computer that runs Windows, see Windows Bluetooth 4.0 User Guide.

1. Turn on the device.


2. Start the Bluetooth on the computer.

Windows: On the taskbar, select Action center > Bluetooth 2


Mac OS: Choose Apple menu > System Preferences, and then click Bluetooth

3. Open mBlock 5 and add your device from “Device Library”.


4. Click “Connect”.

5. In the dialog box that appears, click the “Bluetooth” tab, use the device
automatically detected by mBlock 5, and click “Connect”.
Note:

If multiple devices are detected, choose the device to be connected from the drop-down list box. To display all
2
available devices, select Show all connectable devices.

Connect a device by following the corresponding user guide


For devices produced by other manufacturers, such as micro:bit by BBC, follow the corresponding user manual to
connect it to mBlock 5.

2
Device Library and Extension Center
Device Library and Extension Center
This chapter describes the device library and extension center of mBlock 5. The updates of devices and extensions
are provided in the device library and extension center, and therefore no extra update is needed on the mBlock 5
software.

Device Library and Extension Center

This chapter describes the device library and extension center of mBlock 5. The updates of devices and extensions
are provided in the device library and extension center, and therefore no extra update is needed on the mBlock 5
software.

Device Library

Click the Device tab and click +.

The Device Library page is displayed.


Device Status
A device is in one of the following three states.

(1) Ready to go
In the device library, if a device is shown as follows, it can be directly added.

(2) Update available

If a device is shown with the icon in the upper right corner, a new software version is
available and you can click the icon to update it.
(3) New device

If a device is shown with the icon in the upper right corner, it is newly supported by mBlock 5
and you can click the icon to download it.

Mostly Used Device


1. Click the star tag in the upper left corner of a device to set it to the mostly used device.
2. The mostly used device is displayed on the Device tab when you open mBlock 5 next time, which facilitates your
programming.

Device Extension Center


Click the Device tab and click + extension at the bottom of the Blocks area.
The Extension center page is displayed. The extensions vary according to device.
Extension Status
An extension is in one of the following four states.

(1) Ready to go
In the extension center, if an extension is shown as follows, it can be directly added.

(2) Update available


If an extension is shown with the icon in the upper right corner, a new software version is
available and you can click the icon to update it.

(3) New extension

If an extension is shown with the icon in the upper right corner, it is newly supported by
mBlock 5 and you can click the icon to download it.
(4) Extension added
If an extension is shown with Remove at the bottom, it is already added and you can delete it.

Device Library and Extension Center

This chapter describes the device library and extension center of mBlock 5. The updates of devices and extensions
are provided in the device library and extension center, and therefore no extra update is needed on the mBlock 5
software.
Live and Upload Modes
Live and Upload Modes
mBlock 5 provides two programming modes: Live and Upload. You can click to switch the modes.

Live
In Live mode, you can view the program execution result in real time, which facilitates the debugging of programs. In
addition, you can implement the interaction between devices and sprites by using the broadcast and variable blocks.

Note:

In this mode, you must keep the device connected to mBlock 5. If they are disconnected, programs can’t be executed.

Upload
In Upload mode, you need to upload the compiled programs to devices. After being successfully uploaded, a program
can still run properly on the device when the device is disconnected from mBlock 5.
Programming Languages
Programming Languages
In addition to the block-based programming, mBlock 5 supports Python and Arduino C programming. After connecting
a device to mBlock 5, you can see the programming languages provided for it on the right side.

For example, after connecting CyberPi to mBlock 5, you can see the supported programming languages, as shown in
the following.

You can click Python to turn the scripts area into a Python editor.
Interact with Sprites
Interact with Sprites
On mBlock 5, device programming is separate from stage programming. To enable a device to interact with a sprite,
for example, making the indicators of Halocode on through programming a sprite or enabling a sprite to tell the value
measured by the ultrasonic sensor of mBot, you need to use the broadcast functions to transmit and receive
messages (instructions) and values.

Supported devices, communication modes, and connection modes vary according to broadcast mode. Now, let’s see
how the interaction between a device and sprite is enabled.

Way 1: (Live) Broadcast


In Live mode on mBlock 5, devices and sprites that support broadcasting can communicate with each other by
broadcasting and receiving broadcast messages.

Set the programming mode to Live.

You can see the broadcast blocks in the Events category.

2
Supported Devices
CyberPi, Halocode, Codey, mBot, mBot Ranger, Ultimate 2.0, MegaPi Pro, Neuron, Bluetooth Controller, Arduino Uno,
and Arduino Mega2560

Connection Mode
Live

Application Scenarios
2
A device transmits messages (instructions) to and receives messages (instructions) from a sprite.
A sprite transmits messages (instructions) to and receives messages (instructions) from another sprite.

Application instance
When button A on Codey is pressed, Panda moves to a random position on the stage.
Program Codey as follows.

Program Panda as follows.

2
Press button A on Codey. Does Panda move on the stage?

Way 2: Upload Mode Broadcast


By using the Upload Mode Broadcast extension, devices and sprites that support this mode can interact with each
other.

Note:

Ensure that the device is connected to mBlock 5 when using Upload Mode Broadcast. If being disconnected, the
device cannot interact with sprites properly.

Set the programming to Upload and add the Upload Mode Broadcast extension separately for the device and sprite.

What can we do with a value?

When communicating with each other, a device or sprite can tell the other the type and numerical value of a message.
For example, if Halocode transmits an upload mode broadcast message (volume) with a value (volume of the
microphone) to Panda on the stage, Panda can tell the specific numerical value received in the message.

Supported devices
CyberPi, Codey, Halocode, mBot, mBot Ranger, Arduino Uno, Arduino Mega2560

Connection mode
Upload

Application Scenarios
A device transmits messages (instructions) with values to or receives messages (instructions) with values from a
sprite.
2
Line-following, Breathing light, and other projects that require high efficiency of code operation.

Application instance
When you click Panda on the stage, Codey starts to glance around.
Program Codey as follows.

Program Panda as follows.

2
After completing the program, upload it to the device, keep the device connected to mBlock 5, and click Panda on the
stage. Does Codey glance around?

Way 3: User Cloud Message


By using the User Cloud Message extension, you can share data across devices and projects with the same mBlock
5 account.

Note:

To use the User cloud message extension, a device must provide the Wi-Fi connection function. Currently, only
CyberPi and Halocode are equipped with the Wi-Fi module.

To use the user cloud message function for CyberPi, click the IoT category .

You can see the user cloud message blocks in the blocks area.

To use the user cloud message function for Halocode, click the Wi-Fi category .

You can see the user cloud message blocks in the blocks area.
2
To use the user cloud message function for a sprite, add the User cloud message extension from the extension
center.

2
Connection Mode
Upload

Application Scenarios
A device transmits messages (instructions) with values to or receives messages (instructions) with values from a
sprite.
A device transmits messages (instructions) with values to or receives messages (instructions) with values from
another device.
A sprite transmits messages (instructions) with values to or receives messages (instructions) with values from
another sprite.
Across-region interaction. The physical distance is no longer a restriction. With the same mBlock 5 account, you
can see the noise level of Shenzhen in Beijing.
2
Application instance
When you click the green flag under the stage, the LED indicators on Halocode start to play the rainbow animation.

Program Halocode as follows.


Program Panda as follows.

After completing the program, upload it to Halocode and click the green flag on the stage. Does Halocode play the
2
rainbow animation?

Note:
After Halocode is connected to the Internet, you can also control it remotely by signing in with the same mBlock 5
account on another computer.

You might also like