Morse De-Coder

by SirDan in Circuits > Microcontrollers

2875 Views, 16 Favorites, 0 Comments

Morse De-Coder

IMG_20211006_121010_2.jpg

Everyone has heard of Morse Code, but does anyone actually remember anything other than SOS (...---...)?

This device simply decodes Morse Code into the correct letters and numbers. Use it however you like - whether that's practicing at home, or trying figure out what that flashing torch on a distant hillside is trying to say. You never know, it might save a life!

Supplies

1x BBC micro:bit

1x Computer to upload program

1x MakeCode Website (https://makecode.microbit.org/#editor)

Write Program

sos3.png
sos4.png

This program is written using the easiest programming language ever: MakeCode. It's simply a case of dragging blocks into place. The browser-based software then turns that into javascript, and then into the machine code itself. All you have to do is download it to the micro:bit and your code runs.

Even better, the software provides an emulator that shows exactly what the code does. You can interact with this as you would a physical micro:bit, then use it to test and tweak your code. By the time the code is uploaded to the actual device, all your troubleshooting is already complete.

The software isn't perfect, carrying out more complicated tasks isn't straightforward, but it gets the basics done.

I've designed this device to buffer button presses and figure out what Morse Code character it is. It uses two arrays - one holds the input code in the form of 1's and 0's (replacing dots and dashes), the other holds the output characters (A-Z,1-0). If no match is found, it shows a simple instruction page - dot on the left, dash on the right.

Once the buffer reaches more than 5 dots or dashes, it resets to start the next character. The other way to reset is by pressing both buttons together.

Test Program

sos2.png

Use the emulator to test the program. It allows you to rapidly change code if something doesn't work.

The only thing I missed was recognising the first character in the array. I'd forgotten that the first position in an array is 0, not 1. All I did was add a result that'll never get reached as position 0.

Download and Upload Program

Simply download the program from the website, then upload it into the micro:bit. Simples.

Run It!

IMG_20211006_120948_1_2.jpg

You already know it'll work thanks to the emulator, but it feels so much better once it's in your hands. Test it, press all the buttons to see if it performs as expected.

Use It!

sos.png
800px-International_Morse_Code.svg.png

Get practicing your Morse Code! See if you can decode the dots and dashes of a distant flashing torch. Or if you're not on a hillside, how about trying this for starters:

.... . .-.. .-.. --- / .-- --- .-. .-.. -..


Future Developments

The best project is an unfinished project. Here are some things to add in the future:

  • 3D printed case
  • Actual computer keyboard output, for the advanced Morse Coders out there.
  • Full morse code recognition, including timings and spacings.