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:

Tuesday, 1 November 2016

Little box of horrors - Halloween hacking with pound shop LED lights

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.

Halloween lights

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.

The Raspberry Pi Zero has no audio output, so I added a pHAT DAC from Pimoroni; remembering to use extended headers so I could later add a ProtoZero board to tidily solder the wires onto.

Halloween lights

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:


# Import Python libraries
import RPi.GPIO as GPIO
import time
import pygame
# Set the GPIO caming convention
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Set the GPIO pins for button input and LED output
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.OUT)
pygame.mixer.init()
pygame.mixer.load("Laugh.wav")
while True:
if(GPIO.input(3) ==0):
GPIO.output(24, GPIO.HIGH)
pygame.mixer.music.play()
time.sleep (10)
GPIO.output(24, GPIO.LOW)
GPIO.cleanup

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.

Halloween lights

There are plenty of things I could do to make this better. For instance...

  • 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




Wednesday, 20 June 2012

The Olympic Torch in Thirsk and Northallerton - Storified.

We live slap bang in between Thirsk and Northallerton so went to see the relay twice today. It was nice to see so many people come out and enjoy it, and it's been fun to look at their photos, tweets and videos to make this storify

Monday, 18 June 2012

Olympic Torch Relay comes to Darlington

The Olympic Torch Relay passed through Darlington on Sunday as part of its run through Teesside and County Durham. Despite my workplace being heavily involved in the proceedings I couldn't make it up to Darlo for the day, but I'll be taking Jack and Ed to see the torch when it passes through Thirsk and Northallerton on Wednesday. This is my Storify of Sunday's events with the torch in Darlington.

Wednesday, 30 May 2012

Thirsk; a town in a different class*


Thirsk: in a class of its own
Originally uploaded by westy48
Idly reading Thirsk's Wikipedia entry yesterday I was surprised to see that Thirsk market square was used as a location for one of the photos used in the Pulp album Different Class.

This was the album that included Common People and Disco 2000, and started Jarvis Cockers transformation into a national treasure. I dug out my copy of the CD, snapped a pic with my phone and tweeted it. Graham Denison replied to my tweet suggesting a couple of other Thirsk locations used on the album.




By this morning Thirsk Business Association had also chimed in.

I got out my camera and went for a look. Here's a map with the locations used flagged. Click on the pin to reveal the photo, and click the photo to view a larger size.


View Larger Map

*I nearly called this post "A Thirsk for knowledge" but decided against.

Wednesday, 22 February 2012

Wordle of Brit Award Winning Artists

Wordle: Brit Award winners since 1977

The Guardian loves a bit of data, and today they've released all of the Brit Award winners since 1977 when the awards were launched. Take That and Robbie Williams have clearly dominated, but it's the smaller winners who are more interesting. Who's your favourite winner?