by howardb on Sat Mar 30, 2013 11:56 am

I am using the LPD8806 LED strip with the strandtest.pde that uses LPD8806.h and LPD8806.cpp libraries. The program runs successfully (even though is a hardware failure occurred recently after I got the LED strip and adafruit has generously offered to replace).

Anyway, I want to modify the strandtest code. I am a beginner at C programming. The three files included to run the strandtest program calls a function “strip” (strip.begin, strip.setPixelColor). I cannot find this function in the pde sketch or the LPD8806 .h or LPD8806.cpp libraries.
Can anyone tell me where the strip function is defined?
Posts: 5
Joined: Fri Mar 15, 2013 11:04 pm

by adafruit_support_rick on Sat Mar 30, 2013 12:28 pm

'strip' is a programming "object" which represents your LED strip, not a function. 'begin', 'show', and 'setPixelColors' are the functions, and they located in the LPD8806 library.

Near the top of the strandtest sketch, you'll see this line:
Code: Select all
LPD8806 strip = LPD8806(32, dataPin, clockPin);

What that does is to create an "object" called 'strip', and it tells the 'strip' object that it is going to be controlling 32 LEDs, which are connected to 'dataPin' and 'clockPin'.

dataPin and clockPin are defined a few lines earlier:
Code: Select all
int dataPin = 2;   
int clockPin = 3;

You could have a second strip of, say, 16 LEDs connected to pins 4 and 5. In that case you would declare second 'object' to represent the second LED strip:
Code: Select all
int secondStripDataPin = 4;   
int secondStripClockPin = 5;  LPD8806 secondStrip = LPD8806(16, secondStripDataPin, secondStripClockPin);

When you call a function like show(), you reference the LED strip you want to perform that function on:
Code: Select all;  //perform show function on first strip only;   //perform show function on second strip only
User avatar
Posts: 8421
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

by howardb on Sat Mar 30, 2013 8:06 pm

thanks for that information. I can trace this out now.
Posts: 5
Joined: Fri Mar 15, 2013 11:04 pm