Next up, the software. The Arduino software would be broken into two parts. The first part would be responsible for driving the sounder while the second would be responsible for reading from the key. I started with the sounder because this was by far the easier problem.
I wanted to keep the serial protocol simple. At first I had thought about sending markers for the long and short pulses (and their associated delays) over the wire and having the Arduino client be dumb but by doing so I’d require any server side implementer of the protocol to be smartish. Although I wanted to do this project to interface with Twitter I also wanted to keep it open enough that I could send whatever I wanted along the wire to the telegraph without much fuss (ie: re-implementation of the protocol). I decided on a message format consisting of null terminated strings which would allow for these hypothetical “other purposes” easily.
Completed Arduino source may be found here. I think I’ve managed to comment it pretty well so I wont really get into details here. Also I must confess my difficulty in testing this software. The problem is, I don’t know Morse code. This may seem weird given the nature of the project but the truth is my attachment to the technology is purely romantic. As a result, testing was spotty and difficult. I THINK the patterns emitted are correct and I’m fairly certain the patterns tapped are as well but my confidence is limited by my ability to hear and create those patterns.
Finally, the desktop side software. This I don’t really want to get into. Firstly, that code is a bit of a mess in comparison to the microcontroller code and secondly I utilized open source software packages in its construction and from a legal standpoint with regard to my employer it’s easier for me to just not deal with it here. The general sketch of it is pretty simple, however. First, you need a twitter client package that’ll listen to your feed (or search or mentions or whatever you want sent to the device. The lighter the flow here the better – it takes a long time to tap out a message and you don’t want to worry about running out of buffer or having the thing clack on for hours). From this feed you need to extract the message, massage it into a string containing the user name, and send it over the serial port in a null terminated fashion. You will also need to listen for data on the serial port as well, which will also come across as null terminated strings. This data should be sent off to Twitter as appropriate.
And that’s pretty much it. It was definitely a fun first project for the Arduino and I look forward to doing more work on the platform. Software is great and all but being able to hold and see in front of you the results of your work is definitely a different kind of satisfaction.
Video of telegraph in some phase of development (I forget which):