Morse Code Creator
Step 1 - Build the Project
To create Morse code in blinks, you first need to convert plain characters to ASCII code, then to Morse code, then Morse code to digitalWrite commands.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
First, you’ll create a list of values. This is called an array. The message array holds the plain text characters you’d like to convert to Morse code. The rest of the code can access these letters with a command like: “Go get the 10th thing in the array” and the code will fetch the 10th item in the array.
Second, you will create another array. This array- named morse- holds the dot/dash code for each number and letter of the alphabet.
Next, create your variables. Your variables hold the values for which LED to blink and the time length of Morse dots, dashes, and spaces.
The next chunk of code is a function. It is a group of code that always runs together. It’s like a variable in that you create it, name it, and give it a value. The value of a function is usually a series of tasks to do in order. This particular function is designed to take dots and dashes and convert them to digitalWrite commands. It checks the Morse character and uses your dotLen and dashLen variables to determine how long to blink the light.
In this code, the loop() section is taking the text characters from the message array, making them uppercase, and converting the ASCII number to the corresponding Morse number. You don’t have to convert all of your plain text to ASCII- the computer is doing that automatically.
Next, it passes the Morse array number to signalMorse and says “Here, take this number and do your job with it." The i++ at the bottom of the loop then moves the loop on to the next character in the array.
The signalMorse number receives the Morse array number, which contains the characters made up of dashes and dots. Its job is to unpack the Morse array into single dashes and dots and then blink those dashes and dots. When it is done blinking, signalMorse receives another Morse array number from the loop and repeats.
These functions are interacting with each other, passing values and characters along the chain as they are converted from one character type to another.