Sunday, 27 November 2016

Christmas celebration lights

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..
  • At the moment it plays the same sound every time the button is pressed, but it'd be nice to play a random selection from a playlist of sounds
  • The lights could flicker and flash while the sound plays instead of being constantly on
  • If the sounds are of varying lengths the lights should only be on for as long as each sound plays
  • The lights and sounds could be swapped for Christmas or other gaudily celebrated occasions
  • Spray paint and decorate the box to be a bit less chocolate-boxy
  • Re-write it in gpiozero

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.

  Jumper wires

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!
  • At the moment it plays the same sound every time the button is pressed, but it'd be nice to play a random selection from a playlist of sounds
  • The lights could flicker and flash while the sound plays instead of being constantly on
  • If the sounds are of varying lengths the lights should only be on for as long as each sound plays
  • The lights and sounds could be swapped for Christmas or other gaudily celebrated occasions
  • Spray paint and decorate the box to be a bit less chocolate-boxy
  • Re-write it in gpiozero

Here's the code:

No comments:

Post a Comment