I am trying to work through creating a morse code keyer. I know there are many examples out there, but I have not been able to find what I am interested in yet. In particular, I want to go through this project on my own, keep it simple, and focus on learning how to deal with timing issues on an Arduino.
So, my thought is to separate the input from the key from the output to the speaker. I'd like to be able to record input at any speed and output it at a controlled speed. For example, an expert is able to send morse code at 20 words per minute but I would like to play that back at 5 words per minute.
To do this, I'd like to record all inputs on a pin and store that value in a FIFO buffer (terminology?) so I don't miss any input. Then, I'd like to empty the FIFO buffer at a timed interval that matches the slower speed. This way, I don't miss anything coming in, and I have a chance to test myself as I record the slower speed from the speaker. Think master-slave setup in a classroom (which is what it will be used for)
I have found the SimpleFIFO example, but can't get this to work at all. I am thinking of doing something like the following:
- Every 500ms, read the first entry from the FIFO buffer
- If the entry is a zero in the buffer, do nothing
- If the entry is a one, output a dot
- Advance the buffer one index (terminology?)
- If the entry is a two, output a dash
- Advance the buffer one index (terminology?)
At the same time, record the inputs from the key as fast as possible so I don't miss anything.
I have to be honest, I have lots of experience wiring things, but am self-taught and have no idea how to code something like this. I don't even know what the right words to search for are.
Any help would be greatly appreciated.
Many many thanks,
Ryan