User Cloud Message
The User cloud message function enables data to be shared across devices and projects. To use this function, you need to sign in to mBlock 5.
Let's use HaloCode to understand the User Cloud Message function.
Add HaloCode on the Devices tab. Connect HaloCode to the PC through a USB data cable, and click Connect to connect the HaloCode.
Sign up/Sign in to mBlock 5
Click the Sign up/Sign in icon on the right of the toolbar and follow the instructions.
Control HaloCode Remotely Through "Button"
Create a new project to control HaloCode remotely through the sprite Button.
Add "User Cloud Message"
(1) Click the Sprites tab and click + extension at the bottom of the Blocks area.
(2) In the Extension center dialog box that appears, click + Add at the bottom of User cloud message.
(3) On the editing page, User cloud message blocks are displayed.
Step 1: Program the Sprite "Button"
1. Click × to delete the default sprite Panda on the Sprites tab.
2. Click + on the Sprites tab. In the Sprite Library dialog box that appears, search for button, choose Empty button1, and click OK.
3. Choose Empty button1 on the Sprites tab and drag the Events block when this sprite clicked to the Scripts area.
4. Drag the User cloud message block send user cloud message ( ) to the Scripts area and name the message light_on.
5. Add some effects on Empty button1 to make it look like clicked. Drag the Motion block change y by ( ) to the Scripts area and enter –2, and then drag the Look block set color effect to ( ) to the Scripts area and enter –10.
6. Drag the Control block wait ( ) seconds to the Scripts area and enter 0.2; drag the Motion block change y by ( ) to the Scripts area and enter 2; and drag the Look block set color effect to ( ) to the Scripts area and enter 0.
Step 2: Program HaloCode
Now, let's program HaloCode. Ensure that the name of the message received by HaloCode is the same as that sent by Empty button1.
Connect to the Network
1. Choose HaloCode on the Devices tab and drag the Events block when HaloCode starts up to the Scripts area.
2. Drag the Wi-Fi block connect to Wi-Fi ( ) password () to the Scripts area and enter SSID and password of the wireless network to be connected.
3. To ensure Wi-Fi connection, drag the Control block wait until ( ) to the Scripts area and then drag the Wi-Fi block Wi-Fi connected? to the Scripts area.
4. Drag the Lighting block all LEDs light up ( ) to the Scripts area to indicate that Wi-Fi is connected.
Program the User Cloud Message Function
When HaloCode receives the user cloud message, all LEDs on it are on in red and then are off.
1. Drag the Wi-Fi block when receiving user cloud message ( ) to the Scripts area and enter the name light_on of the message you create.
2. Drag the Lighting block all LEDs light up ( ) to the Scripts area and set the color to red.
3. Drag the Control block wait ( ) seconds to the Scripts area, and then drag the Lighting block light off all LEDs to the Scripts area.
4. Click Upload to upload the program to HaloCode.
5. Click Empty button1 on the stage and see what happens. You can sign in to mBlock 5 on another PC and open the same program to control HaloCode after it is connected to the Internet.
Remote control can be implemented only after you sign in with the same mBlock 5 account.