Programming mBot with mBlock 5

1. Download and install the required software

PC client

To program mBot with mBlock 5, you can use the mBlock 5 PC client or mBlock 5 on the web. 

 

To use the mBlock 5 PC client, you need to download and install it. 

mBlock 5 for Windows

mBlock 5 for Mac

 

On the web

To use mBlock 5 on the web (https://ide.mblock.cc), you need to download and install mLink 2.

mLink2 for Windows

mLink2 for Mac

mLink for Chromebook

 

Note:
Google Chrome is recommended. To download Google Chrome, click Google Chrome.

2. Connect mBot to mBlock 5

You can connect mBot to mBlock 5 through a USB cable or Bluetooth 4.0. If you purchase a 2.4G version, you can also connect it to mBlock 5 through the 2.4G module.

Using a USB cable

Using Bluetooth 4.0 (available only for the Bluetooth version)

Using the 2.4G module (available only for the 2.4G version)

 

In the following operation, mBlock 5 PC client is used. If you use mBlock 5 on the web, open mLink 2 and perform the same steps.

 

Using a USB cable

(1) Use the USB cable delivered with mBot to connect your mBot to a USB port of you computer.

(2) Power on your mBot.

connect-mbot-1.png

(3) On mBlock 5, click + on the Devices tab, select mBot in Device Library, and click OK.

mceclip0.png

 

(4) Click Connect. On the dialog box that appears, click the USB tab and click Connect.

 

mceclip1.png

mBot is successfully connected to mBlock 5 when the message indicating successful connection is displayed.

mceclip3.png

Using Bluetooth 4.0

System requirements:

  • Windows: The version of Bluetooth must be 4.0; for other Bluetooth versions, a Bluetooth 4.0 adapter is recommended (refer to Bluetooth Dongle for detailed instructions).
  • Mac OS: Most of Mac OS models are supported.

(1) Power on your mBot.

connect-mbot-1.png

(2) Turn on the Bluetooth on your PC.

  • Windows: On the task bar, select action center > Bluetooth.
  • Mac OS: Choose Apple menu > System Preferences, then click Bluetooth.

(3) On mBlock 5, click + on the Devices tab, select mBot in Device Library, and click OK.

 

mceclip0.png

 

(4) Click Connect. On the dialog box that appears, click the Bluetooth tab and click Connect.

mceclip4.png

mBot is successfully connected to mBlock 5 when the message indicating successful connection is displayed.

mceclip3.png

 

Using the 2.4G module

Computers with the following systems are recommended:

  • Windows: Windows 7 or later
  • Mac OS: macOS Sierra 10.12 or later

To connect mBot in this way, you need to use the 2.4G module and adapter.

connect-mbot-7.png

You can use them simply by plugging them. No drivers or pairing is required.

(1) Insert the 2.4G module into mCore on mBot and insert the adapter into a USB port of a computer.

(2) Power on your mBot.

connect-mbot-1.png

(3) On mBlock 5, click + on the Devices tab, select mBot in Device Library, and click OK.

 

mceclip0.png

 

(4) Click Connect. On the dialog box that appears, click the 2.G tab and click Connect.

mceclip5.png

After the successful connection, mBlock 5 displays the following information indicating the 2.4G connection.

mceclip6.png

 

Note:
The firmware of mBot can't be updated through 2.4G connection.
If mBlock 5 prompts you to update the firmware of mBot during programming, exit from the the 2.4G connection and connect mBot to mBlock 5 in the USB mode to update its firmware. Then you can connect mBot to mBlock 5 in the 2.4G mode for programming.

3. Set the programming mode

mceclip7.png

mBlock 5 provides two programming modes, namely Live and Upload. You can click to switch the modes.

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 mBot 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 mBot. After being successfully uploaded, the program can still run properly on mBot when it is disconnected from mBlock 5.

 

Now, you can start to program mBot by dragging blocks to the scripts area.

If you have no idea how to program mBot, you can also refer to the example programs to get started.

4. View and use example programs

mceclip9.png

5. View block help

mBlock 5 provides multiple types of blocks for mBot. If you don't understand a block when using it, you can right-click it and click Help that appears.

mceclip10.png

6. Set the programming language

mBlock 5 provides two programming languages for mBot, namely block-based programming and Arduino C. In Upload mode, you can click the buttons on the right to switch the programming languages.

mceclip12.png

In addition, when programming mBot in the block-based language in Upload mode, you can click the switching button on the right to view the corresponding Arduino C statements (obtained by converting the blocks).

mceclip14.png

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.