Remote Control

 

With Wi-Fi and User Cloud Message, Halocode can interact with the stage. In this project, we can make a remote control to light up or light off Halocode's LED ring with stage bulb.

1.png

Enable Upload mode

2.gif

 

Set the background and sprite

1. Delete default sprite Panda

3.gif

 

2. Under "Background", click "Costumes", and then add background "Office3"

4.gif

 

3. Add sprite "bulb", and set the costume to "bulb2"

5.gif

 

4. Adjust the size of bulb (150% of the original size), and place on the table

6.gif

 

Program bulb

5. At the bottom of Blocks Area, click "+ extension", and then add User Cloud Message

7.gif

 

6. Choose Variables block. Click "Make a Variable", and name it "frequency"

8.gif

 

7. Drag an Events block 当when green flag clicked to the Scripts area, and then add a Variables block set (frequency) to (0)

9.gif

 

8. Add an Events block when this sprite clicked, a Variables block change (frequency) by (1), and a User Cloud Message block send user cloud message () with value (). Name the message "switch" and add another Variables block frequency

0.gif

 

9. Add a Control block if () then () else (), two Operators blocks () = () and () mod (), a Variables block frequency. Input "2" and "1"

01.gif

 

10. Add two Looks blocks switch costume to (), and choose "bulb-1" and "bulb-2" respectively

02.gif

 

Halocode connects Wi-Fi

11. Add an Events block when Halocode starts up, a Wi-Fi block connect to Wi-Fi () password (). Input the network name and password of your Wi-Fi

03.gif

 

12. Add a Control block wait until (), a Wi-Fi block Wi-Fi connected?, a Lighting block all LEDs light up (). Set the color to green. Add another Control block wait (1) seconds, and another Lighting block light off all LEDs

04.gif

 

Halocode receives user cloud message

13. Add a Wi-Fi block when receiving user cloud message (switch), a Control block if () then () else (), two Operators blocks () = () and () mod (), a Wi-Fi block user cloud message () value. Input "2" and "1"

05.gif

 

14. Add two Lighting blocks light up all LEDs with color R() G() B() and light off all LEDs

06.gif

 

15. Upload the program

07.gif

Download code


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

Comments

0 comments

Please sign in to leave a comment.