Introduction: Morse Code Translator
Have you ever needed to signal a covert supply drop, or taken part in a clandestine spy mission? If so, you might have used Morse Code. However, for those of us who still love an adventure and a challenge, without having to learn the code, this project is for you.
This project demonstrates a cool morse code translator that will transmit both a light and sound signal. As you type words into your computer, the LED and buzzer will signal the respective morse code letters. Although it may seem relatively complex and expensive, all components are available for low prices online or at an electronics/hobby store. The "brains" are provided by a basic Arduino micro controller and although some introductory programming is involved, this project is quite straightforward. (As far as code, all you have to do is copy and paste my example code and run the application, so never fear.)
Step 1: Materials
The items necessary for completion are listed below:
Arduino Uno micro controller (x1)
USB A to B cable (commonly used in printers)
Any color LED (x1) (I use red in the project)
Solid core #22 guage jumper wire (approximately one foot)
Access to a computer
Free Arduino software IDE installed on the computer--- make sure to download the correct program for you operating system. (Link to download page: http://arduino.cc/en/Main/Software )
Solderless breadboard
Step 2: Install the Software
Step 3: Link-up!
Now plug one end of the cable into the Arduino micro controller and the other end into the computer.
Click on the "tools" button in the toolbar and hover over "board", Make sure your particular model of controller is checked, then select the serial port under "Serial Port". It should be prefixed by /dev/tty.usbmodem/.
See screenshots if you don't understand.
Step 4: Assemble the Circuit
Here are brief instructions on assembling the circuit. Use the above image for a clearer explanation of the connections.
Arduino digital port 2 to LED positive
Arduino digital port 3 to Buzzer positive
LED negative to Arduino Gnd
Buzzer negative to Arduino Gnd
Step 5: Program
Now for the program. Open the Arduino IDE and copy and paste the following code:
Note: if you have had some experience programming Arduino before, you may wonder why I didn't simply replace the long string of "if..else"s that identify each character with a switch case statement. However, after a headache, and a combination of research and troubleshooting, I discovered that the case option can only accept one given value, and not an array of characters. So much for my laziness...
int LED = 2;
int buzzerPin = 3;
int dot = 250;
char* morseLetters[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.","...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.." };
char* morseNumbers[] = {"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};
void setup()
{
pinMode(LED, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
char info;
if (Serial.available() > 0) {
info = Serial.read();
if (info >= 'a' && info <= 'z') { //We can use use this by the fact that each ASCII code is a number
letterId(morseLetters[info - 'a']);
}
else if(info >= 'A' && info <= 'Z') {
letterId(morseLetters[info - 'A']);
}
else if(info >= 0 && info <= 9) {
letterId(morseNumbers[info - 0]);
}
else if(info == ' ') {
delay(dot * 4);
}
}
}
void letterId(char* character) {
int i = 0;
while(character[i] != '\0') {
output(character[i]);
i++;
}
delay(dot * 3);
}
void output(char ID) {
digitalWrite(LED,HIGH);
digitalWrite(buzzerPin,HIGH);
if (ID == '.') {
delay(dot);
}
else {
delay(dot * 3);
}
digitalWrite(LED,LOW);
digitalWrite(buzzerPin,LOW);
delay(dot);
}
Step 6: Run!
After loading the program onto the Arduino IDE, press run. Don't forget to open the serial monitor (the button in the upper righthand with a small magnifying glass), where you can type messages to be translated. Now, in the input field in the serial monitor, write a series of letters, numbers, or spaces and press "send".
You're done! Stand back and enjoy you're handiwork!
For an additional challenge, add code to process punctuation and other symbols.

Participated in the
UP! Contest
5 Discussions
5 years ago
It makes the dots and dashes randome.
5 years ago on Introduction
It didn't work for me???
5 years ago on Introduction
Nice tip. Thanks!
6 years ago on Introduction
The title is misleading. Its not translating morse code its translating plain text.
you type in plain text and it translates it to morse code
If it was a morse code translator it would take received morse code and
tranlate it back into readable text , which is a much more challenging task for an arduino
6 years ago on Step 4