Sunday, 13 December 2015

We were in Wilco yesterday and spotted some battery powered LED xmas lights for the bargain price of £2.50. They seemed ideal for a bit of festive hacking

There were a few types available and I picked up 3 different ones: warm white LEDs on a flexible but fairly rigid wire, some brighter white LEDs encapsulated in a snowflake housing and some traditional multi-colour LEDs.

The strings of LEDs come attached to two AA cells in a neat enclosure with an on/off switch. I snipped the wires fitted jumper wire housings to the end of each so I could plug them straight onto the GPIO header. As the LEDs run on 3v and I was intending to drive them using an 'expendable' model B, I decided not to bother with a series resistor.

I kept the batteries and the holders - these are bound to be useful for other projects (similar boxes can cost almost as much as the whole LED set).

Then I knocked up a quick Python program to run a mixed illuminate sequence for each of the lights.

For the Pi itself, any model will do. I'm planning on using our original model Bs but if you were buying just for this project I'd go for model A+s or o Pi Zero.

In many cases you can get the components even cheaper (per unit) if you're buying larger quantities.

The only other thing you'll need is AA cells to power the motors and (optionally) a wifi dongle if you want to remotely control the robot.

In oder to fit everything onto the chassis shown above I had to drill some extra holes, mainly to accommodate the Pi in its PiBow case and allow the power bank to be slung underneath. Although this worked fine, I wanted to make things simpler so I've been developing a 3D-printed chassis that has slots for the main elements and also allows the Pi (the heaviest part) to sit more towards the centre.

My plan is that over the holidays I'll finish off some of the activity plans for building this in CodeClub next term and share them online.

Tuesday, 1 December 2015

We missed out on a Lego Advent calendar this year so I decided to code up one for the Pi and the SenseHat.

The top 6 rows of the LED matrix are used to show the days on the month, each one being represented by 2 LEDs . Every day a new pair of LEDs illuminates and you can then select them using the joystick to navigate (your cursor is a pair of bright red LEDs). Pressing the joystick as a button will then display the day number followed by a Christmas image or animation created by my son Ozzy.

To make it funky, each day the grid redraws itself with different coloured LEDs in each position.

Everything you need is in this Github repo. Clone it and then run advent.py

Because the images are just 8x8 bit, they can take a little bit of imagination to work out (the Dec 1st is a snowball fight, before you ask!). You can, of course use your own content for each day. The static pictures should go in the pngs folder: name them decx.png, where x is the day. Animations should be added as a list of frames to animations.py (follow the format of the existing ones).