BBC Micro:bit Reads Morse Code With MakeCode

We always have mixed feelings about the drag-and-drop programming languages. But we were impressed with [SirDan’s] Morse code decoder built with the graphical MakeCode. Granted, it is reading 5 element groups from a button on the BBC micro:bit and not worrying about details such as intercharacter or interelement spacing or word spacing. But it is still a nice demo for MakeCode.

Interestingly, the online editor for MakeCode can apparently simulate well enough to test the program. However, [SirDan] only provides the hex file so we couldn’t try it out. There is a screenshot of the visual code, but you’d have to work out the part that didn’t fit on the screenshot (the data arrays are pretty long).

We do like that you can jump between blocks and JavaScript in MakeCode, so it would have been possible to provide a more traditional listing. There are times when you really want to just do something in code, we think.

Purists will argue it really isn’t decoding Morse code because it uses one button for a dot and another button for a dash. But that’s no different than an iambic paddle. You’d still want to fix the timing issues to make it practical for real Morse code operators.

If you want a more practical code reader, try this one. Better still, learn the code. The Ludwig Koch method works for a lot of people.

12 thoughts on “BBC Micro:bit Reads Morse Code With MakeCode

  1. Two buttons is far removed from real code, as is sending directly to a machine.

    There is very little need for knowing what you are sending. It’s receiving that’s “harder”. And generally, that means imperfect sending, the dots and dashes may not be the same length each time, and interference and background noise. So you could program for machine sent code, but it woukd have limitations in real life.

    It’s the imperfections that cause problems with decoding CW.

    1. The trick with reading is to set a threshold window for a short and long pulse rather than an absolute value. If you’re feeling extra fancy, for robustness, you could also compare the surrounding pulses and adjust the window size during the decoding process, to account for, say, the key operator gradually getting faster during a message, perhaps the dash speed towards the end of the message exceeding starting maximum dot speed seen at the start.

  2. @MICHAEL BLACK:

    I’d like to see you explaining maximum likelihood and Kálmán filters to a fledgling teenage programming class.

    I might learn a thing or three from that.

    Pics or it didn’t happen!

    1. I don’t know what the purpose of this is.

      In 1970, I wanted to learn morse code. I bought a telegraph set. And I soon realized it was useless. Anyone can learn to send morse code. It’s the receiving that’s hard. I was ten.

      My comment is based on that.

      1. In the 60’s my older brothers wanted to get their Ham licenses so they bought a code key/trainer that came with an LP record. I remember late nights at our old farmhouse hearing the record dot and dashing each lesson.

  3. I see you are using a picture of microbit V1. The new V2 has built in microphone and speaker. Should make a great encoder/decoder based on sound. If you have mixed feelings about the blocks, there is always micropython and javascript.

  4. If you press the javascript button on the makecode editor you can get the javascript version as well …

    here it is …

    input.onButtonPressed(Button.AB, function () {
    current = “”
    })
    input.onButtonPressed(Button.A, function () {
    if (current.length < 5) {
    current = "" + current + "1"
    } else {
    current = "1"
    }
    })
    input.onButtonPressed(Button.B, function () {
    if (current.length 0) {
    basic.showString(“” + (Letters[Morse.indexOf(current)]))
    } else {
    basic.showLeds(`
    . . . . .
    . . . . .
    # . # # #
    . . . . .
    . . . . .
    `)
    }
    })

Leave a Reply to Al WilliamsCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.