Project – Controlling LEDs from iOS Device on Raspberry Pi

Posted by on May 27, 2013 in General | 11 Comments
Project – Controlling LEDs from iOS Device on Raspberry Pi

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.

Concept sketch

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.

Prototyping LEDBorg App using POP (Prototyping on Paper)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

Testflight

LEDBorg IconI realise not everybody will have access to the iOS SDK, or have the necessary provisioning profiles to deploy onto your device, but you might still want to try this out and have a play.

If you want onto the distro list for a Testflight installation onto your iPad or iPhone drop me an email info@fotosyn.com or sign up at http://tflig.ht/130eS2o

11 Comments

  1. mahtiaivo
    May 28, 2013

    fun to play with :D

    Reply
    • Jim at Fotosyn
      May 28, 2013

      Thanks Severin

      Pleased to hear you’ve got it running. Like I say – early days and an embryonic program for building upon. Perhaps an Array of Raspberry Pis would be do-able sending multiple requests out on colour change. Or a toggle switch between the various devices. I guess too, if you had multiple devices then you could set one up on one device, and another on a separate device.

      Jim

      Reply
  2. Justin H
    May 30, 2013

    Could you submit the app to the App Store? I currently don’t see it.

    Reply
  3. Dustin
    July 9, 2013

    great! I used the NetIO app on this project

    Reply
  4. Jim at Fotosyn
    February 2, 2014

    Just posted a new web-application version – LEDBorg Express.
    More info here…

    http://www.fotosyn.com/introducing-ledborg-express/

    Reply

Leave a Reply

%d bloggers like this: