Installation

To download the Arduino library, use the Arduino library manager.

Open up the Arduino library manager:

Search for the Adafruit LPD8806 library and install it

We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

Example

After installing the LPD8806 library, 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:

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):

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
                }
            }
        }

This guide was first published on Jul 29, 2012. It was last updated on Mar 08, 2024.

This page (Code) was last updated on Mar 08, 2024.

Text editor powered by tinymce.