Morse Code on the BBC micro:bit!

Jack Reichelt
Jul 25, 2018 · 6 min read
The BBC micro:bit
Morse Code Chart
Here’s an example. What does it say? The answer is at the bottom!

Let’s start with the Transmitter.

from microbit import *
import radio
radio.on()
from microbit import *
import radio
radio.on()
while True:
...
from microbit import *
import radio
radio.on()
while True:
if button_a.was_pressed():
radio.send('dot')
if button_b.was_pressed():
radio.send('dash')

And that’s it!

The Receiver Program!

from microbit import *
import music
import radio
radio.on()
while True:
...
from microbit import *
import music
import radio
radio.on()
while True:
r = radio.receive()
from microbit import *
import music
import radio
radio.on()
while True:
r = radio.receive()
if r == 'dot':
...
elif r == 'dash':
...
A micro:bit displaying a “dot” it’s received.
A micro:bit displaying a “dash”
from microbit import *
import music
import radio
radio.on()
while True:
r = radio.receive()
if r == 'dot':
dislay.show(Image('00000:00000:00900:00000:00000'))
...
elif r == 'dash':
dislay.show(Image('00000:00000:99999:00000:00000'))
...
from microbit import *
import music
import radio
radio.on()
while True:
r = radio.receive()
if r == 'dot':
dislay.show(Image('00000:00000:00900:00000:00000'))
music.play('F5:1')
...
elif r == 'dash':
dislay.show(Image('00000:00000:99999:00000:00000'))
music.play('F5:3')
...
from microbit import *
import music
import radio
radio.on()
while True:
r = radio.receive()
if r == 'dot':
dislay.show(Image('00000:00000:00900:00000:00000'))
music.play('F5:1')
display.clear()
sleep(300)
elif r == 'dash':
dislay.show(Image('00000:00000:99999:00000:00000'))
music.play('F5:3')
display.clear()
sleep(300)

Some Common Issues

The answer:

• –     – • • •     – • – •

Grok Learning

Articles about coding by the team at Grok Learning & teacher friends.

Thanks to Christie McMonigal.

Jack Reichelt

Written by

Grok Learning

Articles about coding by the team at Grok Learning & teacher friends.