Last year I made this Twitter display using a Raspberry Pi Zero and a PaPiRus eInk display.
Nothing says “Christmas” like a box of Celebrations – especially one that plays Christmassy music and is lit with LEDs.
I’ve finished the code so that it now randomly chooses one of fifteen snippets from different Christmas songs to play while the LEDs gently pulse. With the addition of some jumper wires you can now choose from several sets of Poundland LEDs in different styles and colours.
If you want to look at the code, here it is:
At the end of my previous post I set a list of potential improvements to the Little Box of Horrors I’d made for Halloween.
This is the list..
Earlier this week I’d a pleasant afternoon cutting and soldering wires. I cut the connections between the Raspberry Pi and the LEDs and soldered jumper wires on so they’re now swappable.
I also returned to Poundland and got a couple of packs of Christmas LEDs. As with the Halloween lights I cut the battery boxes off and soldered jumper wires to the ends, taking care to use red or black jumpers to indicate the polarity of the connections. Now I can choose Christmas or Halloween lights for the box.
Having had fun with hardware I thought I’d better have another go at the code, so I’ve re-written it in GPIO Zero, and discovered as a bonus that it’s really easy to control the LEDs with PWM so you can make them gently pulse on and off.
So in a couple of sessions I’ve crossed three items off my list!
Here’s the code:
Inspired by Les Pounder’s hacking, I spent a quid on some LED pumpkin lights and thought I’d make something fun for the trick-or-treaters this year. I wanted the lights to come on and a spooky sound effect to play when a button is pressed on my little box of horrors.
As Les suggested I removed the battery box from the LEDs, and then extended the wires with some hook up wire. I also found and edited some nice spooky sfx, which I saved onto the Zero.
For the first prototype I connected the LEDs to a GPIO pin and the ground pin and started by writing some code that just made them come on and then go off again after a few seconds. Next I added a button which switched the lights on. Finally I used Pygame mixer to play the audio file at the same time as the lights come on.
The code looks like this:
|.setmode( . )|
|.setup( , . , . )|
|.setup( , . )|
|( .input( ) ):|
|.output( , . )|
|.output( , . )|
I went back to my favourite Instructable on launching Python scripts at startup and then set about cramming it all – including USB powered speakers and a USB power bank – into a Celebrations box that I’d kept because it looked useful. I drilled a small hole in the side to pass the LED’s wires through, and a big hole in the lid for an arcade button. It’s a bit of a squeeze to get to the lid on, but it all just about fits in.
There are plenty of things I could do to make this better. For instance…