Morse Code Twitter Wall: A Bit About Morse Code

Morse code was invented as a way of transmitting alphanumeric data across a telegraph wire. The length of each letter, number, or symbol in Morse is inversely proportional to its English language frequency. The letter “E” is a single dot and “T” is a single dash. Most letters combine the two base “characters” — the letter “J” is a dot and three dashes.

The unit of time in Morse is the dot. A dash should be three dots long, and the space between dashes and dots in a single character is a single dot.

To simplify writing characters in Morse in my Arduino code, I’ve attached the single dot intra-character space to the symbol. So to write a dot, I need to turn on the LED for our dot’s length, then turn it off for the same amount of time.

int DOT_LENGTH = 100;

void dot() {
    setPin(led, HIGH);
    delay(DOT_LENGTH);
    setPin(led, LOW);
    delay(DOT_LENGTH);
}

void dash() {
    setPin(led, HIGH);
    delay(DOT_LENGTH * 3);
    setPin(led, LOW);
    delay(DOT_LENGTH);
}

This enables me to write the letter “L” (dot-dash-dot-dot) very simply as:

dot();
dash();
dot();
dot();

The letter “E” takes 2 × DOT_LENGTH (here, 200 milliseconds) to write: one for the dot, one for the intracharacter space. “T” takes 400 ms. The longest letters contain three dashes and a dot, for 1600 ms.

So with a little math, we can figure out the maximum length of a tweet. The number zero, represented by five dashes, takes the longest to “display”. Since a single dash (400 ms) and its following space (200 ms) takes 600 ms, a zero would take 2200 ms (two seconds). The theoretically longest tweet is therefore 140 zeroes, which would take 140 × 2.2 seconds = 308 seconds to display. (More than five whole minutes!)

Fortunately, this is the very worst case. Assuming a mean tweet length of 68 characters, and a random distribution of letters* such that the average letter length is about 11.25 dot lengths including its intercharacter space, we multiply to find that on average a tweet can be displayed in Morse in 76.5 seconds.

I’ve also set DOT_LENGTH as a constant variable at the top of the program. I can only assume that as I gain more experience reading Morse, I can reduce this number to effectively speed up the “reading” of tweets.

My initial version of the Morse Twitter wall will poll for a new tweet every two minutes. This number is entirely made up. However, it ends up not being that far off base; if an average tweet will take a minute and a quarter to display, then many tweets will be displayed twice before a new tweet is requested.

This also means that I can poll at will rather than at some kind of interval. I was initially afraid of running afoul of Twitter’s API limit (180 requests every 15 minutes), which also had to include my desktop Twitter client’s needs. However, polling for a new tweet would on average happen 12 times every 15 minutes, well below my 180 request limit.

For a woefully outdated introduction to Morse code sponsored by the United States Army Signal Corps (circa 1966), watch this video.

Last time: Project Intro: Morse Code Twitter Wall
Next time: The (Ridiculously Simple) Hardware.


*Since the lengths of the letters in Morse are inversely proportional to their frequency in English text, this particular estimate is higher than it needs to be. However, since I only included letters in this sample, and punctuation and numbers contain five or six dashes or dots, this should even out the error in this estimate.

Leave a Reply

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