Sunday, March 24, 2013, 15:27
I spent my three day spring break this year working with the Raspberry Pi GPIO and learning some more about python in the process. My first task was to get all the necessary GPIO packages installed on one of my dedicated raspbmc machines. The RPi.GPIO Python library was pretty easily installed with pip and was much friendlier to work with than I was expecting.I used an old IDE hard drive cable to interface with the Pi's GPIO pins. This proved to be one of the harder parts of this project since these type of cables don't have the same number of pins as the Pi's GPIO. For lights I used a doubled up white LED + Resistor combination I had lying around.
Image Removed
To start with I just got an initial feel for the outputs by plugging the LEDs into the 3v power and ground. I then used the RPi.GPIO python library to get the lights blinking on and off at a medium pace. The rest of the night was spent trying to think of something more interesting a single light could do.
After some light googling I eventually became inspired by m0xpd's gmail notifier script. I loved how elegant the design was and decided to apply the same concept to read in a text file and display it all in morse code via the LEDs.
Python is such a joy to work with, in about half an hour I was able to finish forking over m0xpd's code into what I wanted. Coolest thing I learned in the process was about anonymous functions by using the keyword lambda. I also found that there aren't any morse code standards for some common ascii characters like asterisks or dashes so I came up with a few substitutions I thought were appropriate.
One of my favourite books is the Tao Te Ching (especially the translation by S. Mitchell), so I decided to use that to power this LED art piece. Here is a video of the project running. The rest of the day was spent monitoring how long it took the contraption to process the entire book. It finished a little while before bed, taking 637 minutes and 4.257 seconds to run through the entirety of the text.
The full code I used for this project is available in an easy to read color scheme at pastie.org here.
Next up on my list of personal things to work on is to extend my old binary bash clock concept to work with the Pi's GPIO. It turns out that there are exactly as many controllable outputs ( Seventeen ) as I need to run the kind of display I want without using a decoder or shift register to address all the LEDs. I've even ordered some ping pong balls to use as LED diffusers. :)
For now though, I'm calling this weekends endeavour finished.
Image Removed