We've seen how it's possible to add analogue pins to an Arduino using Paul Brown's simple MC14051B library, but there's another way to expand the number of digital pins available - and it has been wonderfully seasonally demonstrated by make and activist Pete Taylor in his latest build: an LED-based automated advent calendar.
Based on the artwork of Robert Fiszer, created for charity Concern Worldwide, Pete wanted to make an automated advent calendar that would light up each day as it counted down to Christmas. There were two main issues to overcome: it had to be standalone, and a standard Arduino lacks the number of pins required to run 24 individual LEDs. The former was easy enough to fix: a real-time clock module allows the Arduino to keep accurate track of the time and date, even when power is interrupted. The latter left Pete with two options: individually-addressable LEDs, bumping up the cost, or expanding the number of pins available to the Arduino using shift registers.
Like the analogue multiplexor used by Paul Brown, a shift register allows you to address more than the normal number of pins on an Arduino by reading a serial signal from the Arduino and turning it into a parallel output. Better still, they're designed to be daisy-chained: using four shift register chips soldered into an Adafruit Perma-Proto board, Pete's design is able to drive 36 outputs from a tiny Arduino Micro - enough for the 24-day advent calendar, now hung on the wall of Concern Worldwide's office, and to be repurposed in the future into an automated calendar.
As a spare tinkering time project I thought I would have a go at building an Arduino controlled LED advent calendar that illuminates the relevant day and counts down to the 24th. My requirements needed it to be powered by USB, and that it’s a standalone project with it’s own date clock – as the office IT department would frown upon me installing things on my work PC to run Christmas decorations from. In order to do this I needed to read up on using a battery backed up RTC (Real Time Clock) and a way to control 24 LEDs from my Arduino Micro.