Introduction: Arduino Based Text to Morse Translator
This Instructable was written by R. Kundagrami and edited by Dr. J Leclerc at the Univerity of Houston Department of Mechanical Engineering
The goal of this project is to create a device able to translate a text into its corresponding Morse code. The text is typed by the user on a computer. The Morse code is displayed through a blinking LED.
This project will be accomplished in two parts:
Part I: Set up Arduino board with LED light
Part II: Write and upload the program
these parts will be expanded upon in the Instructable, with detailed explanations and pictures to help you.
Step 1: Introduction to Morse Code
Picture: By Rhey T. Snodgrass & Victor F. Camp, 1922 - Image:Intcode.png and Image:International Morse Code.PNG, Public Domain, https://commons.wikimedia.org/w/index.php?curid=3...
To quote Wikipedia: "Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks." Each letter in the English alphabet, the Arabic Numerals, as well as a few extra Latin letters and punctuation is represented in Morse code by a series of short and long signals called "dots" (short) and "dashes" (long). As previously mentioned, these short and longs signals come come in the form of short and long light flashes, or short and long tones or other sounds.
Starting in 1836, Samuel Morse, Joseph Henry, and Alfred Vail developed an electrical telegraph system. This telegraph conveyed messages through a series of electrical pulses, and a code was needed to convert these pulses to natural language; thus, Morse developed a code that would later become International Morse code. Early telegraphy, however, did not use clicks or light signals; rather, these "short" and "long" electrical signals were recorded as indentations on a moving tape; Morse created his code so that operators could translate the indentations into language. Originally, Morse planned to only transmit numerals in Morse code; operators would look up which numerals corresponded to which words in a code book. However, Alfred Vail extended Morse code to include letters, so it could be used more generally. Eventually, it was realized that people could more efficiently translate Morse code if it were an audible language, and thus the system of dots and dashes was created.
How it works:
Each letter and numeral is assigned a series of dots and dashes, with the more commonly used letters having shorter sequences.
A few rules to remember:
- a dash is worth three dots
- the space between dots or dashes in the same letter is one dot
- the space between two letters is three dots
- the space between two words is seven dots
Step 2: The Materials Needed
- Arduino Board*
- LED light**
- 220 ohm resistor
- soldering wire
- soldering iron
- USB to TTL Serial Converter
*Remark 1: In this Instructable an Arduino Pro Mini was used, but any type of Arduino is suitable.
**Remark 2: A buzzer can be used instead of the led to output the Morse code as sound pulses instead of light flashes.
Step 3: Hardware Setup
source for the schematic picture: http://www.tinyosshop.com/index.php?route=product/...
The hardware used to execute this program consists of three parts, the programmer, the Arduino board and the LED with its resistance. In the picture above, the components have been soldered on a round shaped PCB because we had it available. However any shape for the PCB would work. For explanations on how to solder electronics, you can consult this instructable: https://www.instructables.com/id/How-to-solder/
The Arduino Board:
First solder "legs" or pieces of wire, to the undersides of PIN 10 and the GND PIN closest to PIN 10. Place the two legs through two holes and the circuit board and solder them in place. Add the LED and resistor into two more holes, and underneath, using a soldering iron to melt tin, connect the LED to the resistor, the resistor to PIN 10, and the GND PIN to the LED. This completes a full circuit PIN 10-resistor-LED-GND.
The programmer needs to be connected to a computer using an USB to TTL converter. Furthermore, the programmer needs to be connected to the Arduino board via converter pins, which go through six holes on the short side of the Arduino board. In our setup, the converter pins are simply inserted into the Arduino TTL connections ("holes"). No further soldering has been done. This allows us to completely disconnect the Arduino from the converter. However the electrical contacts can sometimes be bad and prevent the program from being uploaded. For a more reliable connection, you can solder the programmer (or a connector) to the Arduino. You can alternatively use an Arduino Uno (only a USB cable is needed to upload a program).
Step 4: Software Setup (Writing the Program)
The attachment is my code in .ino form with comments to explain it.
In a nutshell the program runs an infinite loop. It checks if there is any incoming data from the serial monitor (keyboard), if so, it checks what type of data it is. If the user has entered a lowercase letter, number, space, or any combination of those, then it signals the LED to light the Morse code for that character or string of characters. The lighting of the LED in Morse code is accomplished through a series of voltage changes into the pin with the LED (10 in this case) and delaying for a certain amount of time. The variable time_base defines the time of a dot. In our example it has been set to 100 milliseconds. Thus a dash will stay on high voltage for 300 milliseconds. Each letter and numeral was individually programmed, so that makes a total of 37 different "If" statements testing for the 37 characters (26 letters, 10 numerals, a space).
How to Upload the Program:
To upload the program from your computer onto the Ardunio board itself, you first have to connect the board to your computer. One end of the USB-TTL serial converter should be connected to the board (specifically, to the micro-programmer); plug in the other end to a USB port in your computer.
You need to have the Arduino IDE installed on the computer (https://www.arduino.cc/en/Main/Software). Start the IDE and indicate what board and processor you're using, and which USB port the Arduino is connected to. This can be done by clicking on "tools" on the top and then changing the board, processor, and port. After your Arduino is connected, click on the upload button (the sideways arrow on the top left). First, your micro-programmer's lights will flash, then the board's light will blink, and the Arduino will be ready for use.
How to Test the Program:
Open the serial monitor (control+shift+M) (in the "tools" section) and type something (using lowercase letters, numbers, and spaces), press enter and watch your Arduino respond with a series of light flashes in Morse code!
The video shows the program being tested on the IDE.
Step 5: Conclusion
Now you have assembled and made a program that converts text into Morse code! This program uses only simple commands, and is therefore easy for a beginner to understand. Furthermore, this program offers a lot of flexibility. The use of variables means that one can easily make the dots and dashes longer/shorter, as well as change the pin to which the LED is connected. Now you have at your fingertips the power to communicate with Morse code!
We have a be nice policy.
Please be positive and constructive.