Skip to content

Morse Code Decoder

This project uses an Arduino Nano clone to decode International Morse Code and display the characters on an LCD display for practicing the sending of intelligible code.

The local mom-n-pop electronics store closed recently, taking with it my source of project boxes. So I built the enclosure and base out of wood which really suits the retro vibe of Morse code. It's great when two hobbies collide.

The details of the project are presented below, but first here's a look at the end result:

The ten-digit wheel centered under the screen selects from a list of expected input speeds. The wheel is read when the button is pushed, and the speed in words-per-minute is displayed on the LCD screen immediately followed by the sounding out and display of CQ at that speed. All other signaling in the video is by me on the key at the bottom of the screen. I didn't quite catch my hand on the key in the video, but you can see the key move.

Words per minute is an odd metric because word lengths vary, and in Morse code even the lengths of letters vary. So PARIS is used as the standard word. Dahs are 3x the length of dits, and there is a dit-length pause between letters; PARIS is 50 dit-lengths long, so 16 wpm is 800 dit-lengths per minute. That gives 0.075 seconds (60/800) for each dit, and 0.225 s for each dah. There is some leeway built into the code, of course, because hitting those values exactly is near impossible.

On the lower left is the "wife switch". It disables the beeping, making the wife happy.

The circuit

Here's the wiring diagram I drew up before starting to solder. It's based very closely on the breadboarded prototype I'd been using. I came up with my own convention for this, but it should make sense. My copy of Fritzing is broken, and this is quicker and easier anyway.

Wiring & soldering guide

Concerning all those pull-down resistors -- I hadn't realized that the digital pins on an Arduino have built-in pull-up resistors available until after starting down this path. If I had used the built-in resistors, reversing the logic so that HIGH means an open circuit, I would have had no resistors on the board. (The current-limiting resistor required for the LED is soldered to the LED lead itself, where it is encased in heat-shrink tubing.) Anyway, I still am not certain whether the Nano, and this Nano clone in particular, has those resistors available on all the same pins as, say, the Uno.

Here's my prototype circuit on a breadboard without the LED, speaker, or the number wheel, though the connections are wired for those. For the "production" unit I used a PCB that has almost the same layout, making it easy to convert the prototype circuit to a permanent soldered version. The PCB has power and ground rails on both sides, as in the wiring diagram, making it simpler to ground those pull-down resistors.

And here's the soldered board. I think the only change from the wiring diagram above is the jumper wire from pin D2 to row 26 and the 3.3v to row 27. These are for the wires from the key, which plug into the connectors soldered to those rows.

Here's the back side of the faceplate with the display, button, speaker, speaker switch, LED, and number wheel. Hot glue is the maker's best friend.

The LCD uses a "backpack" from Adafruit that communicates with the Arduino using the serial i2c protocol. This uses only 4 wires rather than the 12 needed if connecting directly to the LCD board.

It was proving impossible to solder wires to the number wheel whose pins don't work with any type of connector that I've found. They're really made to solder to a PCB, so I used a piece of very thin, flexible protoboard. The five pins on the wheel are soldered to one set of holes, and the wires are soldered to the adjacent set of holes. Then some hot glue makes it rigid.

Here are the main circuit board and the faceplate with all connections. The wires are long enough to keep the faceplate out of the way while screwing the circuit board to the mounts at the bottom of the box.

The code

The code for this is on Github. It's really rather rough, showing many vestigial signs of its evolution, but it works. It should be rewritten, and I would like it to use interrupts for more accurate timing. The key input is on pin D2 which can be used for interrupts. The code currently just polls the inputs.

One thing about the code that I do rather like is the way it interprets the dits and dahs as they are sensed by using a dichomotic search tree. (Honestly, I came up with the technique on my own before I discovered that Wikipedia page and learned the name.) A small Python program to create the data structure containing the search tree in the Arduino sketch is on Github, too.

The case

I recently made a woodworking project with padauk, an African hardwood that's very hard, very red, and very nice to work with. I had some scraps leftover, so I decided I'd use it for this project. I'm not sure of the conservation status of that species, but its use is not restricted as with some endangered exotic woods. In any case, I mostly use left-over ends from the scrap box at the local Rockler store, so I don't really contribute to the market for it.

Here is the box attached to the base. There is no stain on the wood, just a few coats of clear spray lacquer. It's beautiful wood that will naturally darken over time.

The box is made of 1/8" thick pieces of padauk. The corners are joined with 45-degree miters, and there's a 45-degree miter on the top edges to accept the faceplate. I had never used miters like this for a box before, and it's challenging to work with such thin stock, but it turned out pretty good. Reinforcements are glued into the corners because those miters are end-grain to end-grain, which can make for a weak glue joint.

There are rails glued to the bottom sides in the box to give a large-enough target for screws to hold it to the base, and another narrower rail glued onto those to give more surface for glueing to the side of the box. The hole on the side is for access to the Arduino's USB jack, and the small hole on front is for the wires from the key. That label was on the board in the store and I just left it since it's out of sight. California thinks this box will kill you.

The base is 1/4" inch thick, made from two pieces edge-glued into one wide piece. Mounting bolts for the circuit board were epoxied to the base before lacquering. I had to make indents on the side rails in the box to accommodate those bolts. The box is attached to the base with four screws from underneath.

Assembly

The circuit board is screwed to the mounting bolts epoxied to the base in the box, the box being first screwed to the base. The wires connecting the circuit board to the faceplate leave enough working room, barely, to get the circuit board screwed onto the mounts.

The wires are single conductor wires, which are much easier to work with and solder than supple multi-strand wires, but they're stiff. I pre-bent the wires so that they'd fold fairly easily as the faceplate was pressed down. Fortunately no weak solder joints or stress-fatigued wires failed.

The faceplate was then permanently attached with wood glue. If I were to ever need access to the innards, the box can unscrew from the base, but it would be hard to get enough access to do much. It shouldn't be necessary. All the upgrades I have in mind are in software.

Here's the completed device. It runs off of USB power because I need the USB for programming updates, and adding a battery pack connected to Vin would be an unnecessary complication. But I might still add the unnecessary complication of a battery pack attached to the back side with circuitry to feed the USB connector. This 10,000 mAh power bank will keep it alive for days it seems. I'll see what four AAAA batteries will do.

The "telegraph" key, by the way, is not really a key for a telegraph line. This is a ham radio operator's key. In the electrical design of this device it is just a momentary-contact button, of course.

Why

Have you really read this far? You might be wondering why I did this. I am not a ham operator and don't really think I ever will be. Morse code is not a requirement for entry to the ham world now anyway.

I had bought this second-hand Morse key to connect to a buzzer back when my son was trying to earn the Signaling merit badge in Scouts. (That was temporarily resurrected for their 100th anniversary.) He never earned it, but I still had the key, and I always had it in the back of my head that Morse code was one of those skills that I'd like to master just for the heck of it.

I was also looking for an entry Arduino project. My smart projects previously had all used Rasberry Pis of one type or another. I like that those provide a full-blown Linux environment, complete with networked I/O. The input and output options on an Arduino are much more limited but perfectly suited to this project -- a "button" for input and a piezo buzzer, LED and LCD for output. No extra shields or modules required. Arduino is really nice in that it boots almost instantly, and you don't need to worry about graceful shutdowns. Low power consumption is nice if this is going to be battery powered.

Leave a Reply

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