PiGlow night light for the kids

I bought a piglow on a whim a while ago, and yesterday I had some time for tinkering, so I played with turning it into a night light for one of my kids.

Here’s what it does.

PiGlow + init.d boot / shutdown control from Andy Baker on Vimeo.

However, I encountered a couple of glitches and challenges along the way.

I was a bit surprised (but not completely) that the physical location and colour of each LED does not map to a sequence of I2C register values; in other words, if you set LEDs 0 – 17 on sequentially, you get slightly random pattern of different colours of different arms of the spiral of LEDs. I assume that’s simply down to the limitations of routing the PWM outputs PCB tracks  to the LEDs.  So this morning I set about changing the sample code to add an array indexed by LED colour and spiral arm, containing which LED matches. As well as sorting out the colour mappings.

I also changed it’s shutdown processing so it could be triggered by a SIGINT – that then allowed me to add a script to the /etc/init.d directory of boot / shutdown scripts. More info here on which mine is based.  Check it out as there’s information there about installing the script, uninstalling it, and how to test it.

Next step is to add the motion detector from my old house alarm project, and use the frequency of movement trigger the brightness of the light – small rolling over in bed, and it stays did, but a child waking from a bad dream lights up the room nice and bright in comforting colours.

P.S.  Don’t worry, I haven’t given up on Phoebe but the weather is terrible – wind and rain – it’s looking better on Tuesday, so fingers crossed.