0% found this document useful (0 votes)
3 views

Programming-Arduino (1) - Pages-99

Uploaded by

axl1994
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming-Arduino (1) - Pages-99

Uploaded by

axl1994
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

between two letters is the same length as a dash, and the space between two

words is the same duration as seven dots.


For this project, we will not worry about punctuation, although it would be
an interesting exercise for you to try adding this to the sketch. For a full list of all
the Morse characters, see en.wikipedia.org/wiki/Morse_code .

Data
You are going to build this example a step at a time, starting with the data
structure that you are going to use to represent the codes.
It is important to understand that there is no one solution to this problem.
Different programmers will come up with different ways to solve it. So, it is a
mistake to think to yourself, “I would never have come up with that.” Well, no,
quite possibly you would come up with something different and better. Everyone
thinks in different ways, and this solution happens to be the one that first popped
into the author’s head.
Representing the data is all about finding a way of expressing Table 5-2 in C.
In fact, you are going to split the data into two tables: one for the letters, and one
for the numbers. The data structure for the letters is as follows:
char* letters[] = {

".-", "-...", "-.-.", "-..", ".", // A-I

"..-.", "--.", "....", "..",

".---", "-.-", ".-..", "--", "-.", // J-R

"---", ".--.", "--.-", ".-.",

"...", "-", "..-", "...-", ".--", // S-Z

"-..-", "-.--", "--.."

};

You might also like