Program a set of Micro:Bits so that they talk to each other via radio to create a synchonised light show.
-
Connect the Micro:Bit to your computer using the USB cable.
-
Open the MakeCode webpage (makecode.microbit.org) or run the offline versions (pxt serve).
-
Drag these blocks from the Basic group.
-
Design your own image for LEDs
-
Click Download and then follow the instructions to copy the .hex file to your Micro:Bit. The LEDS on the Micro:Bit should light up and show your pattern.
-
Add the radio set group block.
-
Now add an input block that will trigger when Button A is pressed, and fill it with a radio send string block. Enter some text to send as the message.
-
Move your show leds block and add an if... then block so that it is only triggered when a radio message with the same text is received.
-
Find someone else who is at the same point and test your code. Does pressing the A button cause their image to appear on their Micro:Bit?
-
Can you add a pause and a clear screen block so that the image disappears after a few seconds?
-
The Micro:Bits should sometimes re-broadcast the message after they have received it. Use the pick random function to choose a number and only transmit the message again if it matches a certain value.
-
Use the random block again to include a slight pause of up to 5 seconds before re-transmission.
-
Test your code as group. depending on how many Micro:Bits are taking part, you should adjust the random values so that avalanches occur with a frequency you're happy with.
-
Work as a group to extend the project.
- Modify the code that so pressing button B has a different effect.
- Can you coordinate your Micro:Bits so that pressing a button on one causes a text message to be displayed on the Micro:Bits one letter at a time?