In this section we are going to create our most complicated program. I want to make a "Morse Code Trainer" which will read incoming Morse code and display it as text. To do this our program must recognise the presses on the morse key and identify the morse characters that they represent. I am going to implement the program as a state machine and use events to make it work. I hope that you will see from this worked example how you can use a similar design when you are writing your own programs.
Letter:
|
Code:
|
Letter:
|
Code:
|
A
|
·
|
N
|
·
|
B
|
· · ·
|
O
|
|
C
|
· ·
|
P
|
· ·
|
D
|
· ·
|
Q
|
·
|
E
|
·
|
R
|
· ·
|
F
|
· · ·
|
S
|
· · ·
|
G
|
·
|
T
|
|
H
|
· · · ·
|
U
|
· ·
|
I
|
· ·
|
V
|
· · ·
|
J
|
·
|
W
|
·
|
K
|
·
|
X
|
· ·
|
L
|
· · ·
|
Y
|
·
|
M
|
|
Z
|
· ·
|
Numeral:
|
Morse code:
|
1
|
·
|
2
|
· ·
|
3
|
· · ·
|
4
|
· · · ·
|
5
|
· · · · ·
|
6
|
· · · ·
|
7
|
· · ·
|
8
|
· ·
|
9
|
·
|
0
|
|
0
|
|