A couple of weeks ago, I stumbled across Arduino on the web and it sparked my old passion for hw + sw tinkering. Last week I received my first Arduino Duemilanove and I’ve had very little sleep and a lot of fun since then 🙂
I was really into ham radio when I was a kid and I always loved morse code. One of my first hw + sw projects was to use my TRS-80 Color Computer as a morse keyboard for my HW-8 QRP transceiver. So I figured a morse keyboard would be a good starter project for my Arduino adventure.
It turns out that the hardest part of this project was interfacing with a PC (AT or PS/2) keyboard. The protocol (described really nicely at Beyond Logic), is pretty bizarre. I searched around and, to my surprise, couldn’t find an efficient, reliable method for using one of these keyboards with Arduino. The solutions I found online ranged from polling the keyboard’s data and clock lines to using a seperate, dedicated microcontroller to translate the keypresses into standard serial that Arduino can easily understand.
I decided to have the keyboard clock line drive an interrupt in which I could reliably read the data line. Since the processor wouldn’t be polling, there’d be plenty of time to do other things. This worked like a charm. At some point I hope to post a cleaned up version of the keyboard code alone so that it’ll be easier for others to use.
It’s not much to look at, but it was a lot of fun, and if I had some ham radio gear, it’d be very useful as well. For now I’ll have to settle with morse code beeping from a piezo speaker that I ripped from an old wireless phone. I also send morse out on pin 13 which just flashes an LED on my board, but you could easily use it with a transistor to key a transmitter.
The keyboard is fully functional, supporting speeds from 5 to 40 wpm, different weights, and even volume (if you’re using a non-filtered little speaker like I am).
Here are some handy features:
- F1 – set speed in wpm. Valid values are integers between 5 and 40. Press enter after the number. Default value is 20.
- F2 – set “volume”. The way I’m using this, it only works if the speaker is hooked up directly to the pwm output pin of the arduino. If you use a low pass filter then this volume method won’t work. Valid values are integers between 0 and 9. Press enter after the number. Default value is 2.
- F3 – set “weight”. I’m not sure what the technically accurate way to set weight is. My version just varies the length of dahs while leaving dits unaltered. Valid values are between 1 and 5. Deafult value is 3.
- F5 – play back a recorded message.
- Shift-F5 – record a message. Max message length is 100 characters. If you add more RAM then you can bump up the message length and/or add more messages on F6, F7, F8…
There are also a bunch of pro signs available on the keyboard. I can’t remember all of them, but they’re commented in the source. ‘+’ is AR, ENTER is BT, ‘!’ is error, etc.
The sketch is posted here.
Let me know if you find this post useful. Enjoy!