This is the software to go with the Quick & Dirty Iambic Keyer that I built over Christmas 2012 to enable me to learn how to drive my new twin-paddle morse key.
As described in the hardware article, the keyer uses all the available I/O pins on the ATTiny45 and also relies on its internal clock oscillator. This is a nominal 8MHz R-C oscillator so it's not super stable nor is it precisely 8MHz. However, it's good enough for a simple keyer since there's a manual speed control anyway.
The code implements a simple state machine with 5 states. There is an idle state (when neither paddle is pressed), a dot state (when sending a dot), a dash state (when sending a dash) and two wait states which follow the dot and dash states to provide the correct length space between each dot and/or dash.
If one key is held down, the state machine will cycle between the sending and waiting states and send a string of dots or dashes. If both keys are held down the state machine will cycle through 4 states sending alternating dots and dashes.
The speed control is continuously monitored, so the speed can be set "by ear", holding down one or other keys and adjusting the speed until it sounds "right". The speed can be varied from about 12wpm to 40wpm.
The code is licensed under the GNU GPL v2 license so you are free to use, copy, distribute and modify the code within the terms of the GPL. Needless to say, the code has been tested and used extensively by me but comes with no warranty.
You can download the source code here.
Alternatively, if you just wat to use the code you can download the .hex file here.