I’ve been very impressed with the radio module in microbit Python. As an extension to a year 8 microbit lesson I got two of my pupils to test out the awesome firefly project. There was a very magical look of amazement on one girl’s face as she realised she was pushing a button on her microbit and making another one on the other side of the room glow. I then got them to test out the range by walking out the classroom and down the corridor – we ran out of school before it stopped working!
I’ve already written a simple wireless Morse code project as an update of the wired one we used in class last year.
Here’s what I’m going to try next lesson… First I’ll get the pupils to load their microbits with some code to receive messages:
import radio from microbit import * radio.on() while True: incoming = radio.receive() if incoming: display.scroll(incoming) sleep(100)
Then I will broadcast messages to them all from mine using this code (which they won’t see):
import radio from microbit import * radio.on() while True: if button_a.was_pressed(): display.show('A') radio.send('Who are you?') if button_b.was_pressed(): display.show('B') radio.send('My name is Mr Booth') sleep(100)
Then, hopefully after I see my message scrolling across many of the microbit, I will ask what the problem is if we want to use them to communicate with each other. Hopefully this will elicit the response that we need some way of directing messages to individuals – using channels or some form of addressing (plus they have no way of sending a message yet!)
I will then hand out pieces of paper with numbers between 0 and 100 on them, making sure I have 2 copies of each number – preferably given to pupils sat far apart so they won’t know who they’re messaging. (I’ll tell them at this point that I’m monitoring all the messages and numbers even though I’m not to cut down on any nonsense!)
So a pupil with number 20 at the front of the class should now be able to message another pupil at the back of the class with the same number using code like this slotting in their given number as the channel number:
import radio from microbit import * radio.config(channel=20) radio.on() while True: if button_a.was_pressed(): display.show('A') radio.send('Who are you?') if button_b.was_pressed(): display.show('B') radio.send('My name is Sam') incoming = radio.receive() if incoming: display.scroll(incoming) sleep(100)
They could then develop the idea by seeing how close the channels need to be before they interfere with each other. Could they add code to change the channel somehow, perhaps using the shake gesture to select a random channel number in multiples of 10 shown on the display? They can message random people – in a class of 30 you’d get roughly 3 people on the same channel:
import radio import random from microbit import * radio.config(channel=20) radio.on() while True: if accelerometer.was_gesture('shake'): new_channel = random.randrange(10,60,10) display.scroll(str(new_channel)) radio.config(channel=new_channel) if button_a.was_pressed(): display.show('A') radio.send('Who are you?') if button_b.was_pressed(): display.show('B') radio.send('My name is Sam') incoming = radio.receive() if incoming: display.scroll(incoming) sleep(100)
A further extension (or for older groups) could focus on the group addressing features not explored in this simple project.
The plenary will be a discussion of how different text-based methods of communication work – SMS and internet-based services plus radio communication using walkie-talkies.
If you want to try this all you need are 2 microbits and the awesome Mu editor. Let me know if you try something like this or have ideas to develop this.
UPDATE – REFLECTION
I’ve now taught this lesson to a small class of Year 8 pupils and here’s what I discovered…
- Nicolas Tollervey’s firefly project worked really well in class. I had hoped to trigger the glowing under my control but kids being kids they fiddled and pressed the buttons so as they all flashed the code ALL the microbits began to glow. I got them to all press the reset button then turned the lights off, got them to hold them up and asked 1 girl to push button A. Then they all started glowing. Quite a wow factor. I got a lovely bit of knowledge about fireflies from 1 girl who told me that fireflies have a unique pattern to their lights, which leads nicely on to addressing and channels.
- The bit where I broadcast a message worked quite well. About half of the girls got the code typed in without errors and
could see my broadcast message. One questioned the point of it, but that moved us on to what was missing – any way for them to reply and addressing.
- Very few girls got the code to send their own message working. We ran out of time (we had about an hour for the whole lesson), plus there were too many syntax errors caused by typing errors. If they are to type the Python code themselves they need to have recently done Python work and/or a debugging lesson – these girls were coming to it cold after a break of several months. I possibly should have given them code to copy and paste.
- I had some more problems with our VDI and/or Mu seemingly forgetting where the microbits were but not knowing it didn’t know where they were. The symptom is that it says it’s flashing but nothing happens. Still not got to the bottom of this, but I was working with a pupil when this happened and she had not unplugged the device.
Conclusion: the firefly part of the lesson was the most successful! The rest of the lesson can work better with some tweaks outlined above. Will do this again next term!