Skip to content

Instantly share code, notes, and snippets.

@topshed
Last active February 6, 2018 14:36
Show Gist options
  • Save topshed/32031368da774252782f39dd39f10b1c to your computer and use it in GitHub Desktop.
Save topshed/32031368da774252782f39dd39f10b1c to your computer and use it in GitHub Desktop.
Draft activity for CoderDojo starter pack (Micro:Bit Blocks)

Making a Crowd Display with Micro:Bits and MakeCode

Program a set of Micro:Bits so that they talk to each other via radio to create a synchonised light show.

Design your image

  1. Connect the Micro:Bit to your computer using the USB cable.

  2. Open the MakeCode webpage (makecode.microbit.org) or run the offline versions (pxt serve).

  3. Drag these blocks from the Basic group.

    alt text

  4. Design your own image for LEDs

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

    alt text

Setup the radio

  1. Add the radio set group block.

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

    alt text

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

    alt text

  4. 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?

    alt text alt text

  5. Can you add a pause and a clear screen block so that the image disappears after a few seconds?

Triggering an avalanche of messages

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

  2. Use the random block again to include a slight pause of up to 5 seconds before re-transmission.

    alt text

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

  4. 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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment