Twitter Based Christmas Ornaments Update

When we introduced you to the Twitter Christmas tree ornaments, sadly we had very little information about the project. Luckily [Rob] made contact and clued us in on the inner workings. It even turns out we were wrong about the usage of Arduinos! We invite you to check out all the juicy inner workings after the break.

Lets jump right into the explanation,

So the controller uses a single Arduino connected to 3 74HCT595 shift registers.  The ‘595 takes a clock bit and a data bit, and each leading edge (0-1 transition) of the clock bit shifts in a data bit.  Then there’s an 8-bot latch, and the leading edge of another line captures the state of the shift register to the outputs.  Each ‘595 stores 8 bits, can be chained, and there are three of them.  This lets it control 24 lights with only 3 I/O lines.  Each output is connected to a TIP31 transistor, in standard NPN configuration.  The TIP31 can switch up to 3A, so they handle the 1A 6V lamps with no problem.  This is pretty close to the schematic we’re using, except only 24 outputs:

Here’s the sketch I used to control the shift registers:

long count;
unsigned long val;
void setup()
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);

  count = 0x00;
  val = 0;

void loop()
  unsigned long i;

  if (Serial.available())
    char c =;
    if (c >= '0' && c <= '9') {
      val = val * 10 + (c - '0');
    } else if (c == '\n')
      Serial.print("setting count to ");
      count = val;
      val = 0;

  unsigned long bv;
  digitalWrite(10, LOW);
  for (i=0, bv=1; i < 24; ++i, bv <<= 1)
    byte bitval = LOW;
    if (count & bv)
      bitval = HIGH;
    //Serial.print("i ");
    //Serial.print(" bit ");

    digitalWrite(11, bitval);
    digitalWrite(13, HIGH);
    digitalWrite(13, LOW);

  digitalWrite(10, HIGH);

    //count &= 0x3ff;

I bit-banged the SPI protocol, since I was having trouble using the hardware SPI, and figured it was easier than fiddling with registers.  I since discovered the breadboard was a bit flaky, and lowering the bit rate would have probably worked too, but that’s for V2.0 :-)  It listens for a number on the serial port, and shifts that number into the 74595’s.  Lather, rinse, repeat.

The other side is an old netbook, running a Processing sketch – since I didn’t write it, and forgot to ask for permission, I can’t attach it, but the essence is a loop that screen-scrapes Twitter’s search API, and sets the bits of a long corresponding to the words that it finds.  I’m now updating it to blink faster or slower based on the frequency that a word occurs, since words like Christmas seem to appear frequently this time of year, who knew?

Rob D

There you have it. For those wondering, the schematic is actually for an upcoming light control shield [Rob] is working on. You can expect to get your own around April. For those that just can’t get enough Alpha One Labs goodness, be sure to join us for their regular UStream this evening at 7pm EST.

2 thoughts on “Twitter Based Christmas Ornaments Update

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.