LPD8806 LED strip-- code question

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
howardb
 
Posts: 5
Joined: Sat Mar 16, 2013 12:04 am

LPD8806 LED strip-- code question

Post by howardb »

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.show 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?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: LPD8806 LED strip-- code question

Post by adafruit_support_rick »

'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

strip.show();  //perform show function on first strip only
secondStrip.show();   //perform show function on second strip only

User avatar
howardb
 
Posts: 5
Joined: Sat Mar 16, 2013 12:04 am

Re: LPD8806 LED strip-- code question

Post by howardb »

thanks for that information. I can trace this out now.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”