Halocode's Remote Control Deck

 

Sign in to mBlock 5

We can use "User Cloud Message" to control Halocode remotely. We need to sign in to mBlock 5 first.

1.gif

 

Toggle on Upload mode

2.gif

 

Connect to the internet

1. Drag an Events block when Halocode starts up and a Wi-Fi block connect to Wi-Fi () password (). Input the Wi-Fi name and password.

3.gif

 

2. We want to know when the Wi-Fi is successfully connected. Add a Control block wait (), a Wi-Fi block Wi-Fi is connected?, and a Lighting block all LEDs light up ().

4.gif

 

Add a sprite

3. Under "Sprites", click "+". From the pop-up Sprite Library window, choose "Balloon1" from the Props category.

5.gif

 

4. Right click "Balloon1" to make a duplicate. Change the costume to "c", namely color purple.

6.gif

 

5. Delete default sprite "Panda".

7.gif

 

Program the sprite

6. Click "+" in the Blocks area to add "User Cloud Message".

8.gif

 

7. Program the blue balloon. Add an Events block when this sprite clicked and a User Cloud Message block send user cloud message (). Name the message "blue".

9.gif

 

Add some special effects to the balloon

8. When the balloon is clicked, we want it to appear like being clicked. When clicked, the balloon gets brighter and bigger, and goes back to original color and size in 0.3 second. Add the following blocks: change size by (), change (color) effect by (), wait () seconds, set size to (100)%,  set (color) effect to (0).

0.gif

 

9. Likewise, we can program the purple balloon. Add an Events block when this sprite clicked and a User Cloud Message block send user cloud message (). Name the message "purple". Apply the same special effects.

01.png

 

Halocode receives user cloud message

10. Under "Devices", select "Halocode".

11. Add a Wi-Fi block when receiving user cloud message () and input message "blue".

02.gif

 

Set Halocode's LEDs

12. Add a Lighting block all LEDs light up (), change the color to blue. Add a Control block wait () seconds and another Lighting block light off all LEDs.

03.gif

 

13. Likewise, for receiving the "purple" message, duplicate the script, and change LED color to purple.

04.gif

 

Programming result

14. Upload the program to Halocode. Disconnect Halocode from the PC, and use a battery box to power Halocode. Click the balloons on stage, and check the LEDs of Halocode.

05.gif

 

06.gif

Download code


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

Comments

0 comments

Please sign in to leave a comment.