This code was created exploring micro:bit's radio; its bluetooth connectivity.
multipong.py
is a distributed version of the classic Pongcycle.py
sends a message around a group of micro:bits in a cycle.
Clients autoconnect to an existing pool by sending a hello-message when the chip is reset. This hello triggers a reponse from existing clients, resulting in every client knowing what other clients are present; and thereby being able to send a ball over to a different, random client.
Both applications are standalone programs. I recommend the mu-editor.
- Open
multipong.py
in Mu - Connect your micro:bit, and press "flash"
- Repeat this for all micro:bits you want to play on.
On the top of the screen, there is an indicator of who you are (id from 1 to number of players), and the number of players.
ØØ**_
(two bright lights, two lesser lights) means:
- I am number 2 (
ØØ
) - There are 4 clients (
ØØ**
)
A
moves the racket leftB
moves the racket rightreset
triggers a refresh of the other clients, and adds a ball to the game. Use reset on one client after removing a client to get it garbage collected.
Some things that could be expanded on:
- There is currently one ball. Many balls at the same time could be fun
- Showing a scoreboard
An outline to a task based on this code has been made (in Norwegian).