# Case 07: Smart Remote Control Musical Light Level:  
## Sender ### Goal
### Background
Nowadays, different electronic furniture can also be controlled remotely. In this case, it illustrates the concept of remote control in Smart Home. The home owner can control the room atmosphere in the living room by pressing the remote. (Change of music and light)
Principle of Remote (Sender)
-Micro:bit includes the radio function, allowing two or more Micro:bit to form a group and communicate in a small area.
-In this case, this micro:bit sender (Remote) join group 1 with receiver. When we pressed the different button from micro:bit, it will send different message (mode) to another micro:bit so that the receiver will do the corresponding action.
-The message represent the mode which is "Funny", "Exciting" and "Stop Music".

### Assembly step
### Hardware connect
### Programming(Makecode)
* In `on Start`, put a `radio set group 1` to join the radio group 1 
Step 2. Send message to group
* Snap `on button A pressed` to editor * In `on button A pressed`, put a `radio send string funny` to send `funny` message to group 1 micro:bits * Repeat the steps with minor changes on the trigger button and string to create other message sender for `excited` and `stop_music` 
MakeCode: [https://makecode.microbit.org/S03594-89946-74148-89880](https://makecode.microbit.org/S03594-89946-74148-89880)
You could also download the program from the following website:
### Result
When the press the button A, micro:bit sends the `funny` message to `group 1`.

When the press the button B, micro:bit sends the `excited` message to `group 1`.

When the press the button A and B, micro:bit sends the `stop_music` message to `group 1`.

### Think
## Receiver ### Goal
### Background
When this Micro:bit receives the message from the another Micro:bit (Remote), it will use the buzzer to play a different tone or music, at the same time, the multi-color LED will be changed to have better ambience. There are 3 modes, one is enjoyable mode, another is exciting mode, the last one is Stop Music. 
### Part List
### Assembly step
In this case, build the “Big Style Model” as a home base.

Step 2
To build a living room, put model E1 onto model A, align with the holes at model A and B3.

Step 3
Attach the multi-color LED to the model B3 using M4\*10mm screws and nuts. And the connecting wire should be bended to the hole nearby.

Step 4
To build a sofa model. Put the model K3 to the two sides of model K1.

Step 5
Put model K2 all together to the cardboard parts (K1-K3).

Step 6
The sofa completed!

Step 7
Place the sofa at the living room.

Step 8
Put the model H as a decroration display on model B3.

Step 9
Assembly completed!

### Hardware connect
### Programming (MakeCode)
* Create a variable called `mode` * In `on Start`, put a `radio set group 1` to join the radio group 1 * Initialize Multi-Color LED by `set strip to NeoPixel at pin P1 with 1 leds as RGB(GRB format)` * Set the variable mode value to 0 by `set mode to 0` 
Step 2. Examine the radio message and take action
* Snap `on radio received receivedstring` block to editor * Put a nested `if-else` statement inside that block * In the first condition, use `receivedstring = stop_music` to filter out the `stop_music` message, change the `mode` flag variable to `0` * In the second condition, use `receivedstring = funny` to filter out the `funny` message, change the `mode` flag variable to `1` * In the third condition, use `receivedstring = excited` to filter out the `excited` message, change the `mode` flag variable to `2` 
Step 3. Make the change color function
* Create two function called `rainbow` and `flash` * For each function, use `strip show color XXX` and `pause(ms) XXX` to fill in the pattern of color changes as you want 
Step 4. Change LED color by the flag
The color of LED should be change following by the flag Flag | Meaning :| : 0|stop_music 1|funny 2|excited * Put a nested `if-else` statement inside the `Forever` * Use `mode = 0` as the first condition * In the first `if` segment, that's means `stop_music`, stop the playing sound by `stop all sounds` * Turn off the LED by `strip show color black` * Use `mode = 1` as the second condition * In the second `if` segment, that's means `funny`, stop the playing sound by `stop all sounds`, then play a funny music with `start melody prelude repeating once` * Execute the function to change to rainbow pattern by `call Rainbow` * Use `mode = 2` as the third condition * In the third `if` segement, that's means `excited`, stop the playing sound by `stop all sounds`, then play a excited music with `start melody chase repeating once` * Execute the function to change to flash pattern by `call flash` 
MakeCode: [https://makecode.microbit.org/_3PLEfo3pX5r4](https://makecode.microbit.org/_azUYbd8AuXY1)
You could also download the program from the following website:
### Results

### Think