When the first Google AIY kit was launched with MagPi #57, it was clear that the cardboard box containing the kit was too good to waste. The first plan was to cut a hole in the front flap and use it as a photo frame, until I realised that a light box would help me solve a few problems before getting too cocky with custom lighting…
I’ve already built a few small scale experiments with Pimoroni’s Blinkt, controlling it from HomeKit via Homebridge and arcade buttons via API endpoints. I was also keen to build another HAT, and after reading how supposedly difficult it is to control NeoPixels from a Rasperry Pi, it felt like a good excuse to throw some money at the good ship Pimoroni. Adafruit have covered NeoPixels extensively, and between their Raspberry Pi guide and Uberguide, the project started to feel achievable.
Given the quality of the cardboard (seriously Google, consider scaling down to a box company), I decided to try out a few ‘finished product’ details - panel mounted inputs, a power switch and I wanted the box to be operational from simply turning it on. Essentially, I don’t want to have to open the box once it’s finished.
Adafruit’s Neopixels on Raspberry Pi guide covers two methods of connecting the Neopixels - the diode method is much simpler, and can be transferred to a mini Perma-Proto HAT quite easily.
5m LED strips tend to come with JST SM connectors attached to both ends for factory testing, so the spare male JST wiring can be soldered to the HAT to keep everything modular. I’ve also bought some simple 3-wire JST assemblies for future builds.
Again, Adafruit covers the installation process using the rpi_W281x library, and the
strandtest.py example is a great platform to build on. At this stage I’m mainly interested in hardware and control, so the stock animation functions are all I need for now.
I was only planning to control the Neopixels with buttons (and later remote switches), until I found neopixel-rpi-web. The JQuery colour picker plug-in was buggy and possibly deprecated, but I learnt enough from the core structure of the Flask app that it was fairly simple to throw together a quick web interface to control the LEDs. I’ve set up some of the functions from
strandtest.py as endpoints, which also display a webpage when called - to keep a consistent interface, the endpoints just need to return the same
index.html. Buttons on the webpage in turn link to the API endpoints, turning the LEDs on/off and changing colour.
At some point towards the end of the build, the clean-shutdown daemon that drives the On/Off Shim stopped working, and using it will now shutdown the Pi before it has a chance to boot. Until I’ve figured out how to stop this, I’ve added simple shutdown and reboot functions and assigned them to endpoints with buttons on the web app.
The final step was to assign a static IP to the Pi Zero and add a command to crontab to run
lightbox.py at boot, and the lightBox can now function without any SSH interference.
I’m pretty confident in working with NeoPixels now, so the possibilities are endless - I need something to ease myself into laser cutting so later versions will probably use layered acrylic frames and a better diffuser. I’d also like to get hold of LEDs that run at 5V to get rid of the bulky power supply.
In terms of practical uses, this prototype will light my project shoots until the next version is ready. I’m also drawing up ideas for ambient room lighting, and I might play around with Hyperion to add an ambilight to my Kodi media centre (but I have a feeling that’ll be too much).