S.O.S. micro:bit

By Peter Dawyndt, lead coach CoderDojo Waregem
This is a translation. To see peter's original article (in Dutch), go to:https://drive.google.com/drive/u/0/folders/1WoomVXPYnK6432HIxhZ-EaEfUNpSx998


CoderDojo Waregem is always up to something fun. We developed two micro:bit challenges on sending and receiving morsecode. The 8 to 10 year olds started programming their micro:bit by using Google Blockly while the 11 to 12 years olds used Python.

Blockly 

Some scoundrels have kidnapped a few micro:bits from the collection of CoderDojo and have hidden them in the local Dojo. Fortunately, micro:bits can communicate with each other over a simple wireless network by sending radio signals to each other. This allows all abducted micro:bits to transmit an emergency signal consisting of the SOS message in Morse code on a separate channel.
The task of the ninjas is to convert their own micro:bit into a receiver enabling them to find out which emergency signal is being sent out, on which channels emergency signals are sent out and where the micro:bits are located that transmit the emergency signals.
Throughout this task, the ninjas learn to receive radio signals with the micro:bit, and they discover that the strength of the signals received enables them to ascertain their distance from the stolen micro:bit. For most ninjas, this is often a first introduction to Morse code, so prepare for some fun and giggles.

The blockly code (Dutch) can be found on the Google Drive via this link:https://drive.google.com/drive/u/0/folders/1WoomVXPYnK6432HIxhZ-EaEfUNpSx998
If you would like these in English or French, let us know and we will provide a translation. Anyone who wants to translate the documents, can contact us via info@coderdojobelgium.be.

Python

Kids working with Python will learn all about Morse Code.

Morse code 
Morse is an encrypted form of communication consisting of signals that are transmitted intermittently. Defined combinations of these signals represent the different letters, punctuation marks and numbers. This code was invented and developed by Samuel Morse in 1835 for use in the transmission of telegraphic messages. With a telegraph (see figure) one could only choose between two states: key down (= current) or key up (= no current) and duration (short or long). Telegraphy is generally considered as a precursor to later digital communication. Note that in speed races between experienced Morse code operators and experts in sending SMS messages, Morse code invariably wins the game.



The international Morse code uses symbols to write down the code. It indicates short signals with a dot (.) and long signals with a hyphen (-). A short pause is each time inserted between different characters (letter space) and is written with a space. Between different words,a longer pause (word space) is inserted which is written with a slash (/). So is '... ---...' quite commonly known as the representation of S.O.S. in Morse code signal. The text MORSE CODE itself is listed in Morse code as:

--
---
.-.
...
.
/
-.-.
---
-..
.
M
O
R
S
E
(space)
C
O
D
E


For this task, we convert one micro:bit into a telegraph that allows us to send messages in Morse code. We use a second micro:bit to receive the Morse code messages. Because most ninjas have never heard of Morse code before, let them look for an example of the Morse code alphabet online, and briefly explain the principle of Morse code to them. Based on this, we make them reflect on what radio signals we would send with the micro:bit to mimic the transmission of morse code. Eventually we decide to send out the number 1 to indicate the start of a signal (short or long), and to send out the number 0 to indicate the end of the signal.

To get them started, let them convert a micro:bit into a device that transmits 1 and 0 alternately on a fixed channel. We also turn on all the LEDs every time we send out the number 1, and turn off all the LEDs every time we send out the signal 0. This way, the micro:bit also provides visual feedback during the transmission of the signals. We use buttons A and B to transmit the numbers slower or faster, and notice that the LEDs start flashing slower or faster as well.

If your ninjas already have some more experience in writing Python code and working with the radio component of the micro:bit, you can instruct them to write the above code themselves. Otherwise you can go over the above code with them, because they provide the building blocks that can be used to implement the other parts of the assignment.

Now that we have a micro:bit that alternately sends out the numbers 1 and 0 (on channel 25), we let the ninjas convert their micro:bit into a receiver. Each time the micro:bit receives the number 1, all LEDs must be switched on. Each time the micro:bit receives the number 0, all LEDs must be switched off. As feedback, they can verify that their own micro:bit flashes synchronously with the micro:bit that is sending the signals, and that it also starts flashing faster or slower if the signals are sent out faster or slower by the sender.


If the ninjas are able to receive signals, they are ready to convert their micro:bit into a telegraph capable of transmitting the Morse code. In order to do that, they must adjust the code from the first assignment so that button A can be used to send signals in Morse code. If button A Is pressed, the number 1 is sent and all LEDs must be switched on. If button A is released, the number 0 is sent and all LEDs must be switched off. By doing so, the ninjas will learn the difference between the commands is_pressed() and was_pressed(). They should seek a solution to prevent their micro:bit from sending a string of ones when the A button is pressed and a string of zeros when the A button is released.


Now that the ninjas have written code that can send and receive Morse code, you can divide them in pairs and have them send messages to each other. Each couple must use its own channel number. The sender starts by translating a word (or sentence) into Morse code. Next, he can send the Morse code to his partner who will now read the transmitted Morse code and tries to decode the message. Let them experiment on how far they can sit from each other while still receiving radio signals.
If there is still time left in the session, you can organize a match in which one ninja converts a word to Morse code and sends it via its micro:bit on a fixed channel (e.g. channel 25 again). All other ninjas should receive the Morse code via their micro:bit and decode the word as soon as possible. By doing so, the ninjas learn that radio signals are not sent peer-to-peer but via a broadcast.

Practical preparations

On CoderDojo Belgium’s Google Drive, you can find sheets with the different subtasks for the ninjas and a bundle with the preparation and a detailed solution for the coaches. https://drive.google.com/drive/u/0/folders/1WoomVXPYnK6432HIxhZ-EaEfUNpSx998

Challenge for the coaches

Last but not least, an assignment for CoderDojo coaches who want to challenge themselves. Micro:bit Blockly and Micro:bit MicroPython use another protocol to transmit radio signals. Who succeeds in writing a code in Python that can send/receive radio signals according to the protocol used by Blockly? And who succeeds in transmitting/receiving radio signals in Blockly according to the protocol used by MicroPython?

Share your solution and you will be mentioned in our next newsletter.

Comments

  1. I had no idea I could measure the signal strength of the Micro:bit... can't wait to try this!

    About that Morse... surely, a Micro:bit should be able to receive a morse code and immediately translate it to a letter? ;-)

    ReplyDelete
  2. CoderDojo Oostende already tried this: https://twitter.com/Itkovian/status/1008313144534601728

    ReplyDelete
  3. I was inspired by this article:
    https://drive.google.com/open?id=1pzZcosPcjX1jPidTL2Flp2F49yLVxEIT

    ReplyDelete

Post a Comment