Arduino Logo

Arduino made easy: Output messages in Morse code!

In my first Arduino “blinking lights” tutorial, I explained how to get a sketch up and running and point some instructions at the Uno’s #13 LED.

In my second tutorial, we broke apart the example code and learned about the functionality of all the methods hidden inside.

Now we are going to learn a bit about Morse code, and teach our Arduino how to pump out an S.O.S signal. Afterwards, maybe we will even look into writing a script to convert our own messages in Morse code!

Morse Code: What is it, and why does it matter?
These days, people text on their phones and call on their phones. But at one point in time, we didn’t have the ability to send such complicated messages over the airwaves. In 1836, an artist Samuel Morse began work on a long-distance communication system he labled the “Telegraph”. The telegraph sent pulses of electricity over a wire, which could be audibly interpreted as “dots” and “dashes”. Alfred Vail, a machinist in the 1800′s sought to standardize this telecommunicaiton format by researching the most commonly used words and assigning their letters shorter combinations of dashes and dots than their lesser used counterparts. This led to a very efficient method of communication that is extremely easy to implement and doesn’t hurt the bandwidth. Today, Morse code is still used on ships and airplanes for brief communications.

Today’s standardized Morse code is as follows:

morse code

 

As you can see, “S” is written as three dots, and “O” is written as three lines.

So our output for this project must be: · · · – – – · · ·, (dot, dot, dot, dash, dash, dash, dot,dot,dot).

S.O.S is an internationally recognized distress signal, and an excellent starting point for our Arduino project!

Since we already understand the basics of our digitalWrite(), and delay() methods – we just need to move them around to write a simple hard coded S.O.S.

Morse-SOS-Sketch

We created two new methods, dash() and dot(). These methods do exactly what you would expect- produce one(1) dash or one(1) dot. Above in our main loop(), we produced three basic for loops each iterating through the range 0-3 a single time. Once all three loops are completed the main loop resets.

And now we have a very basic S.O.S running on our Arduino!

Console report on Arduino Uno v3:

Sketch uses 1,106 bytes (3%) of program storage space. Maximum is 32,256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.

Next up, I’m gonna write a script to convert your own words to Morse code comprised of dot() and dash() so you can send your own messages out through your Arduino!

Tags: arduino, morse code, planes, save our souls, ships, tutorial
1 reply

Trackbacks & Pingbacks

  1. […] that we have an understanding of what is actually going on here, head over to part three and we will finish up by sequencing the blinks in a way such that they spell out SOS (or anything […]

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply