christmasTree Tutorial from codebender on Vimeo.
This is a tutorial on the christmasTree
library.
christmasTree
is a library for creating interactive ornaments for your Christmas tree that are based on Arduino and the NeoMatrix modules from Adafruit.
The library provides a set of ornaments that you can pick with the additional option of dropping snow.
The library has an accompanying example that displays a random ornament every 10 sec.
Let's examine the code.
At first, we specify the pin to which the data line of the NeoMatrix module is connected (line 20), and further down we create a christmasTree
instance (line 26).
Inside setup, we initialize the instance with begin (line 30), and we set the ornament we want to display by calling setOrnaments
(line 34).
Inside loop, we do some math, we pick at random the new ornament to be drawn (lines 45/47), and later we refresh the matrix (line 53).
There are also two more methods that we can use.
One is the setBrightness(uint8_t brightness)
method that sets the brightness of the pixels. Values range from 0 to 255, where 0 means off, and 255 means full brightness.
And then, there is a shortcut for resetting the matrix. We don't need to make use of the combination setOrnaments/refresh
. We can just call refresh
with the argument that we would otherwise give to setOrnaments
, and get done with a single call.
That's it. Connect your NeoMatrix modules to your Arduino and your power supply.
Just make sure to read Adafruit's NeoPixel Uberguide about the power considerations before you try powering the modules up. Upload the example to your Arduino, and place your new ornaments on your Christmas tree.
You can also use some LED strips to add some color. Just load the strandtest example from Adafruit's NeoPixel library to an Arduino, wrap the tree with the strips, and get ready for Christmas.
That's all folks. We hope you enjoy the library, and if you have any comments or suggestions you can contact us at girder [at] codebender [dot] cc
Sounds are from freesound.org. Schematics were based on Fritzing.