Friday, May 9, 2014

RaspberryPi: Tweeting in Morse Code

It has been months without any idea. With RaspberryPi and my recent interest in Node.js and no interesting ideas around. I decided do a simple project just for fun. Here was the plan:

  • Listen to the tweets on particular topic, keywords, and from specific users
  • Convert it to Morse code
  • Emit the code from sound (beeper) and light (LED) source.
  • Make it testable without RaspberryPi and offline (using Telnet)
So, I wrote a Node.js based code which can be downloaded from my Github repository naishe/tweemorse the code basically does the following stuffs:

  1. Based on what parameter you passed it either starts to listen to Twitter for the keywords and users that you have configured; or it launches a Telnet server on port 23 where you can sent it a message, and it will translate it.
  2. Once the message arrives it is "queued" in a message queue for processing.
  3. There is a queue consumer that takes the messages one by one and converts them into Morse code.
  4. This Morse code gets read character by character "dit" or "dah" or "white space". (You may know more about Morse code from this Wikipedia article.) Based on the character, the output pin is sent either a HIGH or a LOW signal. Here is a rough idea:
    1. dit: short HIGH
    2. dah: long HIGH
    3. transition between two characters: short LOW
    4. white space: long LOW
  5. HIGH means LED and and beeper on, LOW means they are off.
For more details and instructions look the Github repo. And, finally, here is how it looks when I tweeted a SOS:

That's all folks!