Table of Contents

Program a Device

Program a Device

With mBlock 5, you can program hardware devices as well as sprites.

This section uses Halocode as an example.

Connect a device

(1) Use a USB data cable to connect the device to a computer.

image

Note:

If the device is equipped with a power switch, ensure that the device is powered on.

(2) Open mBlock 5, click + add and choose your device in Device Library that appears.

Note:

To use mBlock 5 on the web, you need to run mLink first.

(3) Click Connect.

(4) In the dialog box that appears, use the serial port identified by mBlock 5 and click Connect.

image

(5) After the device is connected, Device connected is displayed.

image

Make your device move

The Blocks area displays various types of blocks, and you can use them to implement various effects.

Now, try to complete the following task: When you press the blue button on Halocode, all the LED indicators on it are lit up in red.

(1) Drag the Events block when button is pressed to the Scripts area.

image

(2) Drag the Lighting block all LEDs light up ( ) to the Scripts area.

(3) Press the blue button on Halocode. Are all the LED indicators on in red?