# 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.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cF87961NimwF_0x%2F0.png?generation=1569477789683305\&alt=media)

**Enable Upload mode**

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cF9BTPSQdLN_um8%2F1.gif?generation=1569477789729204\&alt=media)

**Set the background and sprite**

1\. Delete default sprite Panda

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFAI_y2HiEcLhqL%2F2.gif?generation=1569477789671313\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFBOZML-zydMuZC%2F3.gif?generation=1569477789742570\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFCFLxhiu8HUe3E%2F4.gif?generation=1569477789710863\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFDDbwDGx4ZRuf8%2F5.gif?generation=1569477789705567\&alt=media)

**Program bulb**

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFEbpF7p8s3MiSW%2F6.gif?generation=1569477789738114\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFFEOfxHHP1Rajz%2F7.gif?generation=1569477789710955\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFGZC5e6HGFsVgM%2F8.gif?generation=1569477789766697\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFHKICMcLNwCjXh%2F9.gif?generation=1569477789784325\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFI0NK0l2wtAnON%2F10.gif?generation=1569477789763990\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFJ0VJTm8wKu60k%2F11.gif?generation=1569477789724829\&alt=media)

**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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFKkrOE5pAemp9g%2F12.gif?generation=1569477789758643\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFLnbxL_rsoAWbA%2F13.gif?generation=1569477789754593\&alt=media)

**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"

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFM6IdabH9v8Ti6%2F14.gif?generation=1569477789777571\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFN2gxLJqPMFQyJ%2F15.gif?generation=1569477789774848\&alt=media)

15\. Upload the program

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-Lpg9cFOOU3bzd0_MSim%2F16.gif?generation=1569477789753892\&alt=media)
