How Does Morse Code Work?
The Morse code alphabet, explained: how Alfred Vail's binary tree of dots and dashes turned 26 English letters into the first digital code.
A battery, the device that created the first continuous flow of electricity as a direct current (DC), forms a circuit when the telegraph switch is pressed. Direct current is what the telegraph needs, because a code built from on-and-off pulses depends on the current either flowing or not flowing in a single direction.
Imagine a thousand telegraph circuits all connected to a little bulb. Synchronise those signals and the light will dance. That is not unlike how your television works. Direct current, flowing in one direction like water flowing around your central heating, flips switches on and off. Some of those switches make a liquid crystal red. Some make it green. The result is the illusion of a continuously moving image.
The telegraph, then, is simply a circuit closed by a switch. In a remote location, the closed switch makes a buzzer buzz or a hammer knock a mark onto a bit of paper, which is how the telegraph got its name. Tele for distance and graph for writing.
A code is made up of a source alphabet and a target alphabet. The source alphabet, what programmers might call the source code, is the human-originated form: in our case, the 26 letters of English. The target alphabet, what programmers might call the machine code, is the encoded form that actually travels: in Morse, dots and dashes, written on paper as ‘.’ and ‘-’ but created in the telegraph by a short and a long press of the switch. The code is sent character by character, each character moving quickly but the whole string going slower, with pauses between letters so the receiving operator can decipher them. Here is the full Morse code alphabet:

Can you see that no letter can be mistaken for another? E, a single dot, is the beginning of I, two dots. But two E’s sent in succession cannot be mistaken for I, because in Morse a pause three dots long has to happen between letters. The within-letter gap is short, the between-letter gap is long. This makes each letter unique, which means letters can be decoded as they come in, which in turn explains how experienced operators like Thomas Edison could decode signals by ear. In codes without these pauses a different convention is needed, such as agreeing that every letter is a fixed length. This would be a waste of presses and battery, and would take longer to decipher.
If you look at Morse as a binary tree, which it is since there are only two symbols in the alphabet, then you can see why a variable-length code is quicker:

The letters at the first layer can be reached with one press. The next layer, two. The most infrequent letters are relegated to the bottom layers.
I know what you’re thinking. Did Morse and Vail set out to build a binary tree? Not directly. But they did the kind of analysis that would have led to one. Vail walked into a printing press and looked at the type cases. The biggest piles of metal type were E and T, the letters the printer needed in the greatest quantity because they came up most often. The smallest piles were the rarities, Z and X. From this Vail built a rough frequency table for English and gave the shortest codes to the most-used letters and the longest to the rarest.
Electricity sent down a wire weakens as it travels. After enough distance a dot and a dash both look the same on an oscilloscope, like a comet and its trail. The fix is the relay. The first digital amplifier, Morse’s only real contribution, that recieves the signal before it has degraded and re-transmits it.
And now to my epic - drum roll - conclusion. Every code since Morse uses the same trick. Information is coded into a small alphabet, usually zeroes and ones (the computing equivalent of dot and dash), sent at speed and processed at the other end. The effect on the user, what we call the user illusion, is that these systems think. They do not. But the illusion is powerful.
Where to now?
Samuel Morse and the Telegraph (and the Information Age)
New Haven, 1825. A painter named Finley Morse is in Washington working on a portrait commission when a letter arrives from home. His wife Lucretia has died. By the time he gets back, she has already been buried. He never gets to say goodbye.
What Is a Code? From Brahmi to Samuel Morse
What is a code? I wonder how many people, including people like me who fanny around with computers for a living, ever asked that question?
Why Was Morse Code Invented? The Political Reason Samuel Morse Built the Telegraph
Have you heard the one about Samuel Morse? His wife died but news travelled so slowly that before it reached him her parents had already buried her. If only, Morse cried in anguish, a godlike system existed that could have brought me the news instantly.





