Simple radio data communication using BBC micro:bits

The excellent Python Mu editor makes it a doddle to get micro:bits talking to each other wirelessly – check out the awesome firefly project on this page.

I thought I’d have a go myself, and in no time at all turned 3 Microbits into little glowing, wirelessly-communicating bugs.

Next I had a go at writing some code of my own, first just to send ‘A’ and ‘B’ button presses between micro:bits:

import radio
from microbit import display, button_a, button_b


while True:
    # Buttons send letters
    if button_a.was_pressed():
    if button_b.was_pressed():
    # Read incoming messages
    incoming = radio.receive()
    if incoming == 'A':'A')
    if incoming == 'B':'B')

Then I had a go at sending Morse code – here the A button sends dots, the B button sends dashes. There’s a bit of a delay (300 milliseconds) before the screen blanks so you can see discrete dots and dashes. Next step is to mash this up with a wired morse code project so it will automatically decode messages and display them!

import radio
from microbit import display, button_a, button_b, sleep


while True:
    # Buttons sends a message.
    if button_a.was_pressed():'.')
    if button_b.was_pressed():'-')
    # Read any incoming messages.
    incoming = radio.receive()
    if incoming == '.':'.')
    if incoming == '-':'-')
    sleep(300)' ')
This entry was posted in computers, education, ICT and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>