James West

May include blinky lights. And cocktails.

Tag: LEDs (page 1 of 2)

Greet trick-or-treaters with this Halloween skull

Halloween is the time of year when makers add LEDS and sound effects to cheap goodies bought at pound shops and supermarkets.

I saw this skull in my local Asda, and thought it was ideal for a bit of modding. The cranium is quite rigid, and as it’s hollow there’s room to put stuff inside it. I used my Dremel to drill a 3mm hole in each eye socket, and to cut a square out of the bottom to allow access. I threaded orange LEDs through the hole in the base to each eye hole, and secured them in place with a dollop of hot glue, which also gave the LEDs a nice diffuse look inside the eye socket.

The plan was to have the eyes gently puslsing and to make spooky sound effects play as trick-or-treaters approached. I have a PIR detector in my box of bits and so I connected it to a Raspberry Pi and used the examples from the gpiozero documentation to write some code to use the sensor as a trigger. I’d tried using this sensor before for something and couldn’t get it to work, and again it defeated me. I’m sure there’s a trick to setting the sensitivity pot just right on these things, but I couldn’t make it work so chucked it back in the box for another day.

Instead I decided to add a button so the trick-or-treaters can scare themselves by playing the sounds if they’re brave enough! The illuminated arcade button that came as part of the Google AIY kit with issue 57 of the MagPi was perfect!

Sounds are played with a Pimoroni Speaker pHAT (I love these). I got the audio files from a Spooky sounds CD I bought at Woolies years ago. It plays just over an hour of gruesome sounds, and I edited a few short samples from it to use here.

Having got the electronics and software working I made a stand out of plywood, drilled holes for the button and to allow wires to pass through into to skull, and painted this black.

Paint it black

Once the paint was dry I put all the bits together. Having glued the LEDs to the skull earlier I had to take unfasten them now to let me hide the Raspberry Pi underneath the stand. Threading the wires from the Raspberry Pi, through the top of the stand, into the skull and then into the small holes in the eye sockets was tricky, but some patient fiddling about helped me get there. Really this is just a new version of the box of horrors I made at Halloween a couple of years ago, just don’t tell anyone I’m recycling my ideas!

Rotary phone jukebox

I’m at the age where things which were normal in my childhood are now described as vintage; cars, furniture, radios, and telephones.

I got an old BT rotary dialling phone from eBay a while ago, and have been hanging on to do something with it. We did use it as a phone for a while, but the handset speaker wasn’t great quality and the ring was so loud it made us all jump. This phone has two push-buttons on top – one stopped the bells ringing and the other was labelled “Recall” but didn’t seem to be working – at least not as I’d expect a button labelled recall to function.

I think my phone is a BT model 8746, having been wired with a plug-in jack at the factory. There are lots of websites with detailed information about these old phones which can help you identify the model you’ve got, host circuit diagrams and have useful repair and maintenance guides. Sam Hallas’ site is wonderfully detailed and britishtelephones.com was also useful. There’s also quite a bit of prior art with Raspberry Pis and rotary dialling phones, and I read these helpful posts from Dan Aldred and Giles Booth.

With the lid off

This is what I found inside the phone after I got the case off. I used this diagram to work out where the handset earpiece connected to the board, and the terminals for the handset cradle switch. Using croc clips I connected the dial to the Raspberry Pi’s GPIO and used Dan Aldred’s code to try to read the pulses. I got nothing, which was a bit worrying. I knew the dial was doing something as I used Giles’ LED trick to be able to see pulses. Next I connected the LED to the Raspberry Pi and wrote a few lines of code to make it flash from the GPIO. Nothing again, so I found another Pi (a 2B lurking unused) and tried again. This time the LED flashed and once connected to the phone’s dial I was able to count some pulses, so I diagnosed a dead GPIO on the Zero W and ordered a replacement – the 2B was never going to fit inside the phone!

Although I was now detecting pulses, the Pi was returning inconsistent results. I wasn’t going to be able to accurately report the number being dialled. So I abandoned the crocodile clips and cut the terminal connectors off the wires in the phone and soldered them to the Pi. I had hoped to be able to keep the phone in reasonably original condition so it could be returned to use as a telephone, but as this now wasn’t going to be an option I was free to get a bit more hacky with the phone. The transparent push-buttons on top of the phone looked like they’d make great light pipes so I hot glued an LED into the bottom of each one. These I connected to 3v from the Raspberry Pi via the two-way switch on the cradle, so when the phone is on the hook one lights up red until you pick up the handset when it switches off and the other button lights up green.

Ready to put the case back on

With the dial soldered to the Raspberry Pi I got a cleaner signal from the dial and could now reliably read the number dialled. I added some code to Dan’s example to play a different .wav file for each number between 1 and 9. Dialling 0 switches the Raspberry Pi off. I’ve chosen songs about phone calls or phone conversations, starting with Hanging on the Telephone by Blondie when you dial 1. To get the audio from the Pi into the handset I used a Pimoroni Speakerphat and wired it straight into the handset, having identified the wires for the speaker from the circuit diagram. The output was a bit too loud, so I soldered a 1k resistor into the circuit which made the volume more sensible.

At the moment the music carries on playing even after you hang up the receiver. I should have a go at using the hook switch to stop the playback, but I’m not sure I can squeeze many more wires into the space – it’s surprisingly cramped inside those old phones, despite how big the look from the outside!

The tea time klaxon

We’re lucky enough to have two teenage boys in the house. One of them lurks in the gloom of his bedroom listening to loud, raucous music and doing god knows what on his computer until he can be lured out by offers of food. But sometimes the music is so loud, or the headphones so firmly clamped that he doesn’t hear the call of “Tea time!!!” wafting up the stairs. I could go up to his room to get him, but this is the 21st century and there has to be a better way.

That better way is the Tea Time Klaxon.

Now I just need to send a tweet featuring the secret hashtag to trigger flashing lights and a buzzer to alert the eldest that tea is ready.

Actually, I’ve wanted to find an excuse to make something with one of these LED towers for ages, because they just look so cool, and recently they’ve been discounted at Pimoroni which gave me a good excuse to get one. The tower needs 12v DC so you can’t drive it directly from a Raspberry Pi. Instead I bought a power supply from Amazon – this one, I think and a Pimoroni Automation pHat to handle the switching.

I made a little plywood stand to hide the gubbins, which looks quite neat with a couple of coats of varnish. Inside you can see the Raspberry Pi Zero with Automation pHat hot glued into a corner.

Internals

I wasn’t sure how easy it would be to get the pHat and LED tower talking to each other, but Pimoroni’s python library for the pHat is excellent. It’s simple to read and is well documented so even a non-coder like me can get going with it very quickly. I borrowed a bit of code from their Blinkt! library to help look out for the hashtag on Twitter and was soon ready to go.

My final code is on GitHub, and you can see that it really is straightforward.

I enjoyed making this, it turned out to be much simpler than I first expected. It’s meant as a bit of fun because both our boys are lovely really, even though one does occasionally text us from his room rather than actually come and speak to us.

Maintenance update: learning by fixing

It’s nice to think the things we make just work and will just keep on working, but obviously that’s not a realistic expectation. This week I’ve been back to two projects that needed a bit of love and attention.

I got both projects up and running again, and along the way learned a couple of things which will help me as I do more making.

The first problem was that the yellow LEDs on my global status indicator had stopped working. A quick look at the circuit showed all the connections looked sound, so I shorted across the button connectors to see if there was a problem there and the yellow LEDs all lit up.

Having diagnosed a problem with the button and checking I had a spare in my box of bits, I desoldered the connectors so I could pop it out of the map. Then I decided to try the button again, while it was out of its snug mounting hole. And of course it worked.

Old button works now its not snugly mounted in the frame.

What I think happened is that the hole I’d cut in the board was a bit too tight and was pinching the moving bits of the button that peek out of the sides, stopping something inside the button working properly. So I rotated the button 90 degrees, stuck it back in the map and checked it was going to work before re-soldering the connections to it.

What I learned: components stop working for lots of reasons, not just because they’re broken. I could have saved myself some time by just trying to reposition the button in its hole before starting to take things apart.

The second problem was a corrupt SD card on the Raspberry Pi running my desktop Twitter ticker. I know corrupt SD cards can be a problem for Raspberry Pi users, but until now I’ve never experienced it. When I built the case for the ticker I did consider making the Pi Zero W inside accessible, but that needed more steps and I just wanted the thing finished, so I glued the last panel in place rather than drilling pilot holes and finding some screws to close it up.

Now I used my Dremel to make pilot holes while the case was still in one piece, then levering from the bottom where any screwdriver marks wouldn’t hurt so much I managed to prise the back layer of plywood off the case fairly cleanly.

Raspberry Pi Zero W inside the Twitter ticker.

Then I managed to wriggle the Pi out of the case, reformat the memory card and flash a new OS to it using Etcher. Then I installed Twython and copied my code across and tried to run it. Of course it didn’t work because I’d forgotten to also install oauthlib.

It still didn’t run because I’d forgotten the Pimoroni one line installer for the ScrollpHat HD.

So eventually I got it working and screwed the case together.

Now includes screws!

I learned two things from this fix: if I’m going to blog about how I build these things I should be more comprehensive in writing up the software requirements, and I shouldn’t put Raspberry Pis in cases that aren’t easily openable.

Quick make: Adding LEDs to a world map to show the status of stuff

In a recent sale my local branch of The Works was selling this cork world map. It was only a few quid – even less than the £7 sticker price and I thought it could be improved by adding some LEDs to it.

Today I finally got this sorted, starting out with a test build of the circuit, wiring two groups of LEDs in parallel (blue and yellow to match the buttons I’d got), with a 100 ohm resistor for each one.

I decided where to put the LEDs on the map, and drilled 3mm holes with my Dremel for them. I also marked out where the buttons needed to go and used a craft knife to cut through the layers of cork, corrugated paper and card that make up the sandwich of the board. The LEDs were hot-glued into place after being pushed through the map, Because the board was quite thick they ended up being just about flush with the surface which gives quite a nice effect when they light up.

I also fastened a 3 x AAA battery box onto the back and stuck the power rails from a breadboard nearby to help hook up the LEDs.

Next I soldered a resistor to the cathode of each LED and wired up the buttons and battery pack to the breadboard. Then I connected the LEDs to the power and used electrical tape to cover up the exposed LED legs to prevent an short circuits.

I’m happy with how this came out. The location of the LEDs in this case isn’t important, they can be used to indicate whatever you imagine: the location of Dalek invaders and UNIT forces for instance. You could put them on specific continents or oceans to help with geography homework or show where particular food, animals, or resources come from.

Desktop Twitter ticker

I’ve already made a couple of Raspberry Pi powered Twitter tickers with wildly different display sizes and, honestly, levels of success. Most importantly, they’ve both failed to be wife-compliant; that is they weren’t finished to a standard where I’d be allowed to leave them out and actually make use of them!

With wifi now built in to the Raspberry Pi Zero W, and Pimoroni’s neat Scroll pHat HD available, I wanted to have another go at this, and having learned a lot of general makery-ness over the last couple of years I thought I could manage to box it up in a smart display.

The code was the easiest part of this project; I just had to modify my previous efforts to work with the Scroll pHat HD rather then the PaPirus Zero or LED matrices I’d used before and add some GPIOZero bits to get the buttons working. You can see the code on GitHub.

Perpendicular Pi

Raspberry Pi Zero W lies flat, but hidden behind the Scroll pHat HD and ProtoZero board

The hardware was straightforward too. I used a right-angle header on the Pi which connected to a ProtoZero board with a long female header to plug into the Scroll pHat HD. I soldered the wires for my two buttons onto the ProtoZero. I needed the Pi to lie flat so I could connect power into it while the display was standing upright. (I’ve used ProtoZero boards in several of my projects, they’re really useful for breaking out GPIOs and neatly soldering your buttons, LEDs and other bits and pieces onto.)

The case was the bit I expected to find most difficult. I wasn’t good at woodwork at school, and haven’t done anything like this before.

Drawings

I did a lot of head-scratching and drawing before making any cuts.

But I had a plan.

I thought I could sandwich together sheets of plywood with a hole cut through the middle of them to make the case. There was some transparent red acrylic left over from supersecretproject#2 that would make a nice diffuser for the really very bright LEDs on the display.

So I did a lot of measuring of the assembeled hardware and drew my pictures, before heading out to treat myself to a jigsaw. This was a good decision.

A slice of the box

It doesn’t matter how scruffy the hole in the middle is, as long as there’s clearance to get the Raspberry Pi Zero W and Scroll pHat HD through there.

I cut the plywood into biscuits and then drilled out the corners of the big hole I was about to jigsaw out of the piece. I made nine of these to accommodate the hardware, and then the front and back plates with feet to stand the box up on the table. I made a tidier hole in the front panel to show the display through, but drilled just a 12mm hole in the bottom corner of the back piece for the power lead. I used wood glue to glue the front half together in one stack, including the plastic and front panel, and then glued the back half separately. I drilled holes for the buttons into the top of this back half and then sanded everything down, rounded the corners slightly and gave it a varnish. This really brought out the colours in the different layers of ply and I think looks rather nice. I pushed the nuts to secure the buttons onto the wires, soldered up the buttons and threaded then into the holes I’d drilled into the top.

Now I did a last test of everything before gluing it all up and happily found everything worked as it should.

Then I glued the rear half onto the front, pushing the Scroll pHat HD right up against the acrylic, threaded the power wire through the rear hole and plugged it back into the Pi and glued the final back slice onto the sandwich.

When it all dried everything still worked, but the feet weren’t quite the same height and it wobbled when you pressed the buttons, so I sanded a few millimetres off the offending foot and gave myself a strong and stable foundation for the project!

This slideshow requires JavaScript.

I’m pleased with how this one has come out, and think it’s certainly wife-compliant, but as always I’d love to hear your suggestions for improvements in the comments.

UPDATE: Alex Burns tried to run the code from GitHub and found it wouldn’t run. This is because the Twython OAuth packages only install for Python 3 so you have to force the program to run in Python 3. To do this I typed the following at the command line:
python3 scrolltwitter.py

ANOTHER UPDATE: It turns out that buttons and a display make a versatile hardware platform, so to grant a request from a family member I just had to write a new program to create a “Sleeps-til-Christmas-ometer”1.

VW badge with LED rainbow

Wallpaper - Not VW camper vans

Not VW camper vans

When we redecorated the hall we went to B&Q in search of some wallpaper to run up the stairs. You know the stuff; probably floral. But then we saw this, and just had to get it.

We’re not massive VW fans, but the dream is to get some sort of camper van when we retire and hit the road, so it’s a little nod towards what might be.

When Cora, our neighbour, gave up her Golf she kept the badges off it’s boot and radiator, and when she saw this wallpaper she gave us one of them. I went to eBay and got a display frame to put it in, and it’s lived on the radiator shelf at the bottom of the stairs since then.

But it’s not felt quite finished; after all, everything can be improved by adding LEDs to it. There was (of course) a spare Raspberry Pi Zero and Blinkt! stick in my makers’ box, so I Dremmelled a Blinkt! sized slot in the bottom of the frame, poked the LEDs through and screwed the Zero onto the bottom of the box.

I’ve not done any fancy code, it just runs the rainbow.py script from Pimoroni’s Blinkt! library.

PS: This video was made with Apple’s Clips app. I really made it as an excuse to play with the app, which is a lot of fun and not that difficult to get started with.

Quick make: cocktail cabinet LED rainbow

We love our cocktail cabinet, bought at a vintage shop in Northallerton. But you can improve everything by adding LEDs to it, right?

Cocktail cabinet lights

After finishing my K9 build I’ve time to spend on a few smaller ideas I’ve had kicking around, like how to make the cocktail cabinet glow. I splurged on a Mote kit from Pimoroni and the pHat to go with it. I made a simple frame from some plywood that was in the shed and screwed the Mote strips to the outside edges. A Pi Zero W went in the middle and I threaded the cables through the gaps I’d left at the corners.

Mote sticks frame

A couple of screw eyes and some picture wire let me hang it on a picture hook behind the cabinet. I’ve just got one of the example scripts provided by Pimoroni running for the rainbow effect, but in the future I’d like to make the LEDs flash or change colour in response to a Twitter hashtag like #cocktailtime

I also think it’s time for that wallpaper to go, and paint a nice clean white wall instead.

Christmas Celebrations – chocolate box LEDs with music

Nothing says “Christmas” like a box of Celebrations – especially one that plays Christmassy music and is lit with LEDs.

Untitled

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.

Merry Christmas LEDs
Christmas Celebrations

If you want to look at the code, here it is:

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:

Older posts

© 2018 James West

Theme by Anders NorenUp ↑