Learning a programming language is not that difficult. However, finding out how a for loop works, and how to declare variables is not the tricky part of programming. The tricky part is taking a problem (make me a morse code reader) and deciding how you are going to write a program to do this.
There are a number of different techniques which you can use to attack a problem like this, we are going to look at something I have mentioned earlier, the State Machine. I am going to treat the system I am going to create as a device which can occupy one of a number of possible states. As humans we are used to this idea in devices around us, for example a radio can be either switched on or switched off. A tape recorder can be either stopped, playing, recording or rewinding etc. In the case of our morse code decoder we need to think about the states that it will occupy.
Look at the system as described on the right and try to identify states within its operation.
The system will wait until the user starts to enter a morse code character.
During entry of the morse character the system will record the dots and dashes, and also keep track of the length of the sequence entered.
Upon completion of the entry of the character the system will display the character received and then wait for another character to arrive.