Now write the code to make your micro:bit behave like a firefly.
Everyone in the group needs to decide on a radio group number. This number is an ID number, so that all the micro:bits can talk to each other as part of one group. The number must be between 0 and 255.
Use this code:
Make the virtual firefly ‘flash’ the avatar. Use code to flash it randomly between 5 and 10 seconds apart.
Here’s one way you could do that:
How might you change this code so it flashes less frequently?
Create a code so that any time your firefly flashes, your micro:bit broadcasts a message so the other fireflies in your group will flash too.
Use your knowledge of the radio blocks to add this to the appropriate place in the code.
Here's a hint, If you need one:
Add code so that if you receive a message over Bluetooth (because another firefly in your group is flashing), your firefly will flash at the same time too.
What block do you need to use?
Use the same avatar or code a new one.
Download the code to your micro:bit and test it out with other people in the workshop.