Installation

To download the Arduino library, visit the repository on GitHub . Click the DOWNLOAD ZIP button near the upper left, extract the archive and then rename the uncompressed folder to LPD8806. Confirm that this folder contains the files LPD8806.cpp and LPD8806.h and the examples folder.

Place the LPD8806 folder inside your Arduino libraries folder. You may need to create this folder if it does not yet exist. In Windows, this would be (home folder)\My Documents\Arduino\Libraries and for Mac or Linux is (home folder)/Documents/Arduino/Libraries. We also have a tutorial on library installation.

After installing the LPD8806 library, restart the Arduino IDE. You should now be able to access the sample code by navigating through menus in this order: File→Sketchbook→Libraries→LPD8806→strandtest

strandtest is written for a one meter LED strip attached to Arduino pins 2 and 3. If you're using a longer or shorter strip, you should change this line:

Copy Code
LPD8806 strip = LPD8806(32, dataPin, clockPin);

so that the first argument to the object is the number of LEDs in your strip. Each meter has 32 LEDs so count them or do the math. Now upload it to your Arduino, your strip should start to perform a bunch of demonstration tests! (The 'longstrandtest' sketch already has this change made for a full 5 meter strip.)

The other two example sketches — LEDbeltKit and advancedLEDbeltKit — are part of a kit based on a different controller board, and won’t work on a standard Arduino without modification. This is just a matter of pin assignments…if you’re crafty you should be able to figure it out.

Netduino and LPD8806 based strips

Driving these strips from Netduino (or other .Net Micro Framwork boards like FEZ Panda) is very convenient and doesn't require a code library if SPI ports are used. The following sample shows driving a 32 pixel light strip connected to SPI1 (SCLK on pin 13 and MOSI on pin 11):

Copy Code
using Microsoft.SPOT.Hardware;
...
        public static void LightStripSpi()
        {
            var spi = new SPI(new SPI.Configuration(Cpu.Pin.GPIO_NONE,
                false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1));
            var colors = new byte[3 * 32];
            var zeros = new byte[3 * ((32 + 63) / 64)];

            while (true)
            {
                // all pixels off
                for (int i = 0; i < colors.Length; ++i) colors[i] = (byte)(0x80 | 0);
                // a progressive yellow/red blend
                for (byte i = 0; i < 32; ++i)
                {
                    colors[i * 3 + 1] = 0x80 | 32;
                    colors[i * 3 + 0] = (byte)(0x80 | (32 - i));
                    spi.Write(colors);
                    spi.Write(zeros);
                    Thread.Sleep(1000 / 32); // march at 32 pixels per second
                }
            }
        }
Last updated on 2014-04-16 at 12.33.18 AM Published on 2012-07-29 at 03.58.38 PM