Tiny Morse Code USB Keyboard

We’ve featured quite a few of [mitxela]’s projects here in the past, and many of them have the propensity to be labelled “smallest”. His Morse Code USB Keyboard Mk II adds to that list. It’s a Saturday afternoon project, with a few parts slapped onto a piece of perf-board, that allows using a Morse key as a USB keyboard. This project isn’t new or fresh, but we stumbled across it while trying to figure out a use for a Morse key lying in the author’s bin of parts. You can practise transmitting, by reading text and typing it out on the key, and then look it up on your computer to see if you made any mistakes. Or you can practise receiving, by asking a friend to punch it out for you. Either way, it’s a great way to hone your skills and prepare for your radio operators license exam.

The project is a follow up to his earlier one where he hooked up the Morse key via a RS-232 — USB converter directly to a computer and let the code do all the work. That turned out to be a very resource hungry, impractical project and made him do it right the next time around. The hardware is dead simple. An ATtiny85, a piezo buzzer, some decoupling capacitors, and a few resistors and zeners to allow a safe USB interface. The design accommodates a straight key, but there is one spare pin left over in the ATtiny to allow for iambic or sideswiper keys too. There is no speed adjustment, which is hardcoded at the moment. That isn’t very user friendly, and [mitxela] suggests adding a speed potentiometer to that last remaining pin on the ATtiny. This would prevent use of iambic/sideswiper keys. Or, you could use the RST pin on the ATtiny as a (weak) IO. The RST pin can read analog values between 5V and 2.5V, and will reset when voltage falls below 2.2V. Or just use another microcontroller as a last resort.

For the USB interface, [mitxela] is using the V-USB library after wasting some time trying to reinvent the wheel. And since this is designed to work as a HID, there are no drivers required – plug it in, and the OS detects it as a keyboard. He’s borrowed code from the EasyLogger project to use the internal oscillator and help free up the IO pins. And to detect the characters being typed, his code uses a long string of compare statements instead of a dictionary lookup. Writing that code was tedious, but it makes the identification quicker, since most characters can be identified in less that five comparisons (one dit = E, two dits = I, three dits = S and so on). This “tree” makes it easier to figure it out.

If you’d like to look up some of his other “tiny” projects, check out The smallest MIDI synthesizer, Smallest MIDI synth, again! and the ATtiny MIDI plug synth.

24 thoughts on “Tiny Morse Code USB Keyboard

  1. This is very cool. I wonder if speed could be a power-on calibration, like it’s disables until you send a few dots and dashes (SOS?) to measure your timing then it begins conversion

    I’ve seen morse trees before, they make no logical sense – seems like more to memorise than just the patterns alone

    1. You’re right that memorization is the best route for humans… the tree is for the benefit of the processor .

      Interesting project. I still wanna learn Morse code, even if it’s falling out of use.

      1. The best advise I have heard for learning Morse is to have the characters sent fast (20 WPM) with a ‘think about it’ delay that spaces the throughput to 3-5 WPM.

        This helps you to memorize the characters more as a musical rythym.

      2. It has seen a large resurgence of use in the amateur radio community since the requirement for knowing Morse Code was removed from the licensing. I know that sounds counter-intuitive, but I suspect it has to do with people learning/using it because they want to rather than because they have to.

  2. I did something like this a few years back. But I dead bugged the decoder chip from a keyboard pcb and put a spring under one end and a cardboard hinge on the other. One of the pins acted as a contract to some tinfoil.

  3. It is possible to use only one pin to read both keys from an iambic keyer using resistors and configuring the pin as an analog input. It is possible also to detect a very long press, like 5 seconds, as a trigger to a function that changes the speed using the dit-dash keys as plus and minus controls, typing in the speed value as ascii characters..
    This project is great, and might be implemented to act as a PS/2 keyboard controller also, thus allowing to use the PS/2 input that is free on many desktop computers yet today.

  4. I’d love to see this become a commercial product with some marvelously helpful changes.

    1. Instead of a straight key, put the entire device in a small tube with a momentary switch on the end as the key. That’d make it easily held and operated.

    2. Instead of powering it from USB, power it from a single AAA battery inside that tube. That eliminates the need for a USB cable for power.

    3. Make it emulate a Bluetooth keyboard rather than a USB one. Again, no need for a cable and an important plus, that’d let it work with smartphones and tablets that aren’t designed to be used with a USB keyboard.

    The result would be a text-entry device for mobile devices that’d be easy to use in situations where a conventional keyboard and a touchscreen one are impractical. It’s also be marvelous for those with physical disabilities who’re familiar with a Morse UI.

    And sell it commercially! Hacking without follow-on production accomplishes little.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.