What you have here is an array of string literals.
So, because a string literal is
actually an array of char , what you actually have here is an array of arrays— something that is perfectly legal and really quite useful. This means that to find Morse for A , you would access letters[0] , which would give you the string .- . This approach is not terribly efficient, because you are using a whole byte (eight bits) of memory to represent a dash or a dot, which could be represented in a bit. However, you can easily justify this approach by saying that the total number of bytes is still only about 90 and we do have 2048 bytes to play with. Equally importantly, it makes the code easy to understand. Numbers use the same approach: char* numbers[] = {
"-----", ".----", "..---", "...--", "....-",
".....", "-....", "--...", "---..", "----."};
Globals and Setup
You need to define a couple of global variables: one for the delay period for a dot, and one to define which pin the LED is attached to: const int dotDelay = 200;
const int ledPin = 13;
The setup function is pretty simple; you just need to set the ledPin as an output and set up the serial port: void setup()