Over the past few weeks I have been experimenting with the Raspberry Pi, more so as a means to test out some ideas of linking iOS devices to other services over an internet connection. The Raspberry Pi, being a server in its own right, and having other cool hardware breakout options seemed like a good place to start.
I’ve been playing around with the new Camera module, as well as a nifty three element LED unit from Pi-Borg.
The LEDBorg is a great way to explore the options of using services like Python to receive instructions from iPhones and iPads, and the idea of changing a light on a board from a touch screen UI seemed pretty cool.
Starting out with an idea for a basic app, and using POP (Prototyping on Paper) from Woomoo I drafted out an idea of what the app could do. At the same time, I started writing some basic services for the RPi to receive instructions to change the LEDs as the user interacts with the iOS app.
The Raspberry Pi side of things was a fairly simple implementation. Using SimpleHTTPServer within Python, gave me a lightweight – almost ad-hoc HTTP service which could receive queries. These queries, parsed for the values Red, Green and Blue and then passed to the LEDBorg to change the colour of the LED. This in itself is very straightforwards, using a chain of Bright, Normal and Off for the RGB elements to create ‘mixed’ colours.
Within the LEDBorg the colours are interpreted as
2 – Bright
1 – Normal
0 – Off
If you’re familiar with mixing colours you’ll get the gist. Mixing a full red with full green, makes a yellow. Full red with half green makes orange; full red and blue, magenta and so on.
The app itself was written over two days on a long weekend. I’ve deliberately kept the functionality minimal, that will allow it to be easily extended or customised. There are some UI elements which are quite handy to test both colour mixes and the set palette, and to easily change settings. It’s a universal app with variants for iPad and iPhone/iPod.
Settings include defining the IP address the RPi is running on, as well as the port SimpleHTTPServer is listening on. This is set at :8000 as default but can also be customised within the controlling Python script.
Being a proof-of-concept, it’s more of a testbed, or springboard for other developers who might be looking to use something similar in a different installation. Likewise, it’s a good catalyst for picking up Python and getting your hands dirty with some code. Here’s the app in action…
Repo and other useful links
If you’d like to have a look at this concept in more detail, or just want to play around you can find the repo for all the source code (Python/Obj-C) at https://bitbucket.org/fotosyn/fotosynlabs/src/
Raspberry Pi Foundation http://www.raspberrypi.org/
Get your own LEDBorg http://www.piborg.com/ledborg/
POP (Prototyping on Paper) http://popapp.in
Adafruit WebIDE for Python http://learn.adafruit.com/webide
The Testflight for LEDBorg is no longer available. You can however run the web app version, LEDBorg Express.