After getting the Arduino to encode Morse messages and send them to a connected Max patch (see the last blogpost), I took the next step. So far, I built a way to create messages, and a way to transmit them, but not everyone was able to simply read and understand morse code, so the next step was obvious: build a way the messages could be read in clear text. The idea was simple: after every message got “sent”, the Arduino would take the Morse code string and convert it into readable text.
My first attempt was a long list of if statements, which worked, but I had hoped for an easier way to add and administrate different dot & dash combinations. Next I thought of using a switch statement to iterate through the combinations, but Arduino doesn’t support those, so I had to come up with a new idea. After searching on the internet, I came across a different solution, using arrays. So I rewrote it using arrays that mapped Morse code strings to letters. That gave me something that felt like a switch statement. It was now much cleaner, and easier to add custom combinations later.
Before:

After:

The decoding worked like this: one array was filled with all the Morse code symbols, and one with the matching letters. The code then iterated through the Morse message character by character, building a temporary substring that represented a single Morse symbol (like “.-” or “–“). Whenever it hit a slash (/), the program knew it had reached the end of one symbol. It then compared the collected substring to all entries in the Morse array. When it found a match, it took the corresponding index in the letter array to find the translation. That translated letter got added to the final decoded message string.
To figure out how many slashes were pressed, the code counted how many consecutive / characters appeared in the string. Each time it found a slash, it increased a counter. When a non-slash character came next (or the message ended), it used the number of counted slashes to determine the type of break:
- One slash (
/) meant a new letter started. - Two slashes (
//) meant a new word started. - Three slashes (
///) meant the start of a new sentence. - Four slashes (
////) marked the end of the message.
This system worked surprisingly well and gave me more control over formatting the final message. By using these simple separators, I could organise the output clearly and logically. Here is how the full print would look like with the translation.

The result? A very basic but fully functional Morse communication device: input, output, transmission, and now decoding. Currently it is just displaying the message in the serial monitor, but I plan to make the message be displayed on the LED Matrix, on the Arduino, that way the message is readable to the user immediately. I also read online, that an Arduino can be connected to a web server, so I will probably test that out, since this way I could create smart devices for my room on my own.
Instructions
If you wanted to try it out yourself, here was what you needed:
- An Arduino (compatible with Modulinos)
- The three button Modulino
- The latest sketch with decoding logic (I could share this if you were interested)
Not a lot to do, except plugging in the three button Modulino and uploading this sketch: