We will now build a two-directional network with multiple micro:bits. In order to do this effectively, we need to define the communication protocol so that the rules of data transmission are established.
We will create a network for a game of silent tip.
At least 3 microbits
1 power pack per microbit
1 usb cable
Form groups of at least three numbered players (1, 2, 3...), each player with a micro:bit. Players must stay in their seats within the classroom
An image display on the micro:bit LED Matrix indicates if the player is in or not (e.g. GHOST for in and PACMAN for not it)
Player '1' starts 'in'. Using their micro:bit, they need to 'tip' another student in their game by sending that person's number to their micro:bit. As the micro:bit only has two buttons, you will need to encode the number in binary with 'a' representing a 0 and button 'b' representing a 1. For example, to tip person 3, they would need to send the binary number '11'. To indicate the number has been completed, the gold logo is touched and the person's number is transmitted to all micro:bits. The player cannot tip themselves.
The person who has just been tipped will see their display change (e.g. to a GHOST) so then needs to tip another student using the same process.
The game is played for a set period of time. Once the time is up, the person who is in loses and is out of the game. The remanding people play until only one remains - the final winner!
6. Code the micro:bit using the code in picture. Add comments to demonstrate your understanding.
7. Test in the simulator, observing the radio signal which is being sent.
8. Download to micro:bit '1'
9. Modify the code, changing the ID number, tipped to False, and display Image.PACMAN.Â
10. Attach battery packs to each micro:bit. Microbit'1' should have the GHOST and the rest should have the PACMAN
11. Test the game, starting with micro:bit '1'
What protocols allow this game to work?
What are some of the problems with the function of this game system? How could the code be modified to address this?
One improvement to the game would be to allow players to 'dodge' a tip. Suggest how you could code this including the protocol for communication between micro:bits.