And it looks great too!
This post should have been made 6 weeks ago or so, but I just couldn’t find the time with all the other things I wanted (and some which I just had) to do. But this week I realized that delaying this post any longer would probably mean it would never be made, so I sat down, read my last post about this project to see where I had ended.
The Arduino Ethernet has been replaced by an Arduino Duemilanove, because when I found out how easy it is to flash an Arduino from a Raspberry Pi, the Arduino Ethernet wasn’t the best tool for the job anymore – an Arduino Duemilanove was a better choice actually – powered by a USB cable between the Arduino and a RPi meant that I didn’t need a power supply and flashing became a breeze. Another great plus was that I could now use Serial() on the Arduino instead of Ethernet.
So how does this contraption work? The Raspberry Pi that’s near the Arduino runs a Node.JS script. This script basically controls the ‘state’ in which the Arduino is. With the serialport module this Node script can send commands to the Arduino like ‘reset’, ‘on’, ‘off’, ‘day’, ‘night’, ‘demo’, ‘stop’.
The reset command triggers a ‘reboot’ of the Arduino by jumping to address 0. The on/off commands are used to tell the Arduino whether it should act on the light barriers being broken or not, day and night tell the Arduino whether it’s day or night in our world (which has it’s effect on the brightness of the LED strips), and the demo command… well, you can do amazing stuff with 13 individual LED strips! 😉
And of course the Arduino is Serial.print()-ing everything it does: it reports when a light barrier triggers, changes in brightness levels of the LED strips and so on.
The Node.JS script on the Raspberry is partly controlled by the rules engine I use (for day- and night-mode obviously, and for ‘off’ when nobody’s at home.
But not everything went as smooth as I thought it would. After installing everything near the stairs (RPi, Arduino, 16-channel LED driver) something continuously triggered the IR light barriers! What the …? I checked every wire, and again, and again… but I couldn’t find anything wrong, so the only thing I could do was go back in time and reconstruct everything to how it was when it did work. From there I moved forward again until the problem came back. Conclusion, after a really long Sunday: interference. I used UTP cable (a single pair) to connect the IR light barrier LEDS to the Velleman MK120 PCB – this worked well during testing in the lab, but not in the cupboard under the stairs! Too many cables over there that influenced the signal on the unshielded wires I used. Stupid, I should have known this, I guess. I just have to face the fact that I’m not good at this kind of things… after replacing the wire with a piece of shielded microphone wire everything worked again.
Some last minor adjustments in the code here and there like the interval between each LED strip switching on and the project was finished – everything worked just the way I wanted it to, the visual result is impressive and worth all the time & energy that were needed to complete it all.
And here’s the long awaited video and some pictures I made of the end result; enjoy!