3rd December, from the backup vaults of David Whale’s email inbox…missing some photos, I’ll get those up soon!
As a very simple project I decided to try and hook up my RGB strip to my pi, to the internet, and then let people mess about with what colour the LEDs are and what LED to turn on and off.
This turns out to be pretty easy using a couple of libraries I found, so I thought I’d share my progress:
Yesterday I went off to maplin, got a wireless adapter for a tenner (I’m still a bit miffed I caved on that one – ebay has them for a fiver but I didn’t want to wait…), and downloaded the first library:
I then had to install a dependency called websockets-client (use pip install websockets-client).
I first ran the example code, which is under Led_Strip_Library/examples, called “simple_example”. This basically makes all the LEDs turn off and turn on again rapidly. After getting excited about doing that, I fiddled around with the colours a bit and then moved on to Spacebrew.
I only know about spacebrew because the other example in there, spacebrew_bar_graph, uses it, and I think because it’s in beta that’s why I hadn’t heard of it before. This is made by the same LAB who did the above code, and it’s again, stupidly simple to use. I modified the code in spacebrew_bar_graph a little to fix a bug, and then ran it, and hey look, my LED strip’s on the internet:
The admin page shown there is the sandbox server Spacebrew provides, which has open access to anyone in the world, so you could modify your own LED strip to be connected to someone’s button anywhere in the world, for example.
The only thing I don’t like about this is that erm. I’ve not actually written much code…but I have to modify the examples a little in order to change it so that a user can select one of the 36 LEDs and light it up, or a range of LEDs, rather than just a brightness slider (although right now I just tell it to light them all…).
However I will definitely be using this in the future, and now that I have my python spacebrew app on my pi running on boot, that means I don’t even have to SSH to connect a web app to it, so long as both devices have wifi.