petes-brain

NeoPixel Christmas House December 9, 2015

IMG_1625We have these Christmas houses that the Mrs digs out each year.  I suppose that would be a Christmas village…  Anyway, they’re painted ceramic houses, chock full of fiber optic wire, which pokes out around windows, doors and signs and through bits of snow on each roof.  Within each is a small motor that turns a rainbow striped color wheel.  The wheel is transparent and sits just above a small incandescent lamp.  All of this is poised just beneath the bundled end of the a fore mentioned fiber strands with the result being that the exterior of each house slowly shifts color, the change washing across the surface in a wave.

IMG_1626Cute as they are, they scare the crap out of any sensible homeowner who’s spouse wants to run them nonstop during the holiday season.  But as luck would have it, one of the motors died 2 years back.  It was in the “Candy Shoppe”.  I jumped at the chance to do an autopsy only to be terrified to see that the lamp had, over it’s decade of service, begun to brown the plastic housing that enclosed the mechanism.  But I failed to order parts, the season got busy, time fled and soon the-Candy-Shoppe went back into storage.  Another season came and went before I got tired of seeing the lonely lump of porcelain sitting at the edge of the village, in darkness.

 

<sniff> Ok, let’s light this popsicle stand.  But in doing so let’s nerf the moving parts and for the love of peace of mind, let’s use some lamps that don’t get so hot.

Supplies:IMG_1620

 

Tools:

  • Your soldering tools, nothing fancy
  • Something to trim wires with
  • Some tape; maybe masking tape

 

Hardware:

Honestly this is a super easy build.  If you’ve never worked with Adafruit’s NeoPixels or Trinkets you have a bit of reading to do, but not to much.  Here and here respectively.  We’ll also assume that you’ve taken the time to set up your Arduino IDE to work with the Trinket.

K, with that out of the way there really isn’t much left to do.  The name of the game is to set up our circuit, simple as it is, on the back of the jewel, leaving only a connection to the trinket via our 3 jumpers.

  1. Insert your capacitor through the back side of the Jewel, making sure to align it properly so that the light colored band down the side is on tied to one of the GND pins on the Jewel.  Also be sure to leave room to cram your power jumpers into the same holes.IMG_1627
  2. Now you’ll need to stuff your positive (+) jumper through the PWR hole the Jewel.  The anode (long leg) of your cap should already be there.  With both pieces in place, solder them in.
  3. Repeat this step for the ground (-) jumper, being sure to use the same pin on the jewel for both the cap’s cathode (short leg) and the jumper’s male end.
  4. Trim down your resistor, leaving only 1/8″ or so of material on each side and solder it onto the end of the male end of your data jumper.  Solder the remaining end into the data pin on the jewel.
  5. Finally, connect the 5V and GND lines from your Jewel to the the corresponding pins on your Trinket.  Connect the data jumper on your Jewel to pin 4 on your Trinket.

Trim and clean up your wires and we’re ready to get our software in order.

IMG_1631

Software:

This too will be pretty straight forward.  We’ll just be using the “strandtest” example sketch that comes with Adafruit’s Neopixel library (which you can grab here if you don’t have it already).

  1. Load the NeoPixel strandtest example sketch from File->Examples->Adafruit_NeoPixel->strandtest.
  2. Edit the data pin setting at the top of the file to reflect pin 4, where we attached the data pin or your Jewel (line 3 in my copy).
  3. Scroll down to the main loop of the sketch.  It will look something like this:
    void loop() {
      // Some example procedures showing how to display to the pixels:
      colorWipe(strip.Color(255, 0, 0), 50); // Red
      colorWipe(strip.Color(0, 255, 0), 50); // Green
      colorWipe(strip.Color(0, 0, 255), 50); // Blue
      // Send a theater pixel chase in...
      theaterChase(strip.Color(127, 127, 127), 50); // White
      theaterChase(strip.Color(127,   0,   0), 50); // Red
      theaterChase(strip.Color(  0,   0, 127), 50); // Blue
    
      rainbow(20);
      rainbowCycle(20);
      theaterChaseRainbow(50);
    }
  4. Using pairs of forward slashes at the beginning of the relevant lines, comment out any of the functions that you do not want to run.  Try them all to see what fits best (I settled on “rainbow(60)”; note that I changed the wait time to slow down the sequence).
  5. We’re almost there.  The trinket can only be programmed by the Arduino IDE during the first several seconds after it is powered on.  One you’ve set your board to “Adafruit Trinket 8MHz” and your Programmer to “USBTinyISP” (both under “Tools”), connect your trinket to you computer and upload the sketch.

And with that your Jewel should begin cycling through the sequence that you selected.  Obviously, this sketch on scratches the surface of what can be done.  Try all of the sample functions in the strandtest sketch to find what you like best or perhaps write your own.  Adafruit has a great library for working with the pixels that gets most of the hard work done for you.

IMG_1634

 

Install:

This portion was almost to easy.  In my case a bit of masking tape holds the Jewel in place within the house and I use a spare USB charging nut that I have to power the trinket.  One interesting possibility would be to use a single Trinket to drive Jewels in multiple houses.  That would require a bit more power planning than I have time for at present though, so perhaps next year.

And that’s it!  Good luck.

 

 


Categories Uncategorized

Leave a Reply