LPD8806 questions.....

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
slurry bowl
 
Posts: 156
Joined: Sun Nov 11, 2012 6:37 pm

LPD8806 questions.....

Post by slurry bowl »

Hello good people.

I have made great strides in understanding the existing libraries for the LPD8806.

THANKS ADAFRUIT.

I am trying to understand the advanced belt kit code and it is over my head.

I love how the patterns fade into each other, working with channels, etc....

I am trying to write some code that would do this:

1. Divide the total LED strip into 2 lengths, its continuous, so in code, separate them.
- both divisions would fade between magenta, turquoise, and blue, but rotate through those colors so often the 2 sides of the strip are in opposition(turquoise/magenta) (blue/magenta), etc...and occasionally they are the same.

what function does a fade between colors? is there one?

any input would be much appreciated. Thanks !!! cant wait to post some pics of my project!

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: LPD8806 questions.....

Post by pburgess »

You can always use the Arduino 'map' function to interpolate between two values...then do this separately each for red, green and blue:

Code: Select all

// Magenta:
#define COLOR1_R 255
#define COLOR1_G 0
#define COLOR1_B 255
// Blue:
#define COLOR2_R 0
#define COLOR2_G 0
#define COLOR2_B 255

top = 42; // maximum value of counter
x = (some value from 0 to 'top');
r = map(x, 0, top, COLOR1_R, COLOR2_R);
g = map(x, 0, top, COLOR1_G, COLOR2_G);
b = map(x, 0, top, COLOR1_B, COLOR2_B);
A fair bit of math can be saved if you know certain components are the same between the colors (e.g. only red varies in the above example, so the green and blue calculations could be left out altogether, just using the constants in their place.

User avatar
slurry bowl
 
Posts: 156
Joined: Sun Nov 11, 2012 6:37 pm

Re: LPD8806 questions.....

Post by slurry bowl »

Thanks Phil,

I keep trying to put the map function in the code, assuming its supposed to work in the ADVANCED LED BELT KIT code.

I attempted to define Top because I was getting an error message and decided in the setup it needed to be an int.

Feeling lost on how to achieve this simple task of color fading.

Can you recommend any tutorials?

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: LPD8806 questions.....

Post by pburgess »

Ah yeah, I'm sorry about that...that was supposed to be just fake and incomplete pseudocode to give an idea, and wouldn't actually compile as-is. But yes, declaring 'top' as an int would probably work, or you can use a #define since the value won't be changing.

Also, think I goofed on the color values...with the LPD8806, these should top out at 127 (brighest) rather than 255.

User avatar
slurry bowl
 
Posts: 156
Joined: Sun Nov 11, 2012 6:37 pm

Re: LPD8806 questions.....

Post by slurry bowl »

seems 255 is the right #.

Out of all the example codes in the LPD8806 library, which would be the easiest to add this code into?

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: LPD8806 questions.....

Post by pburgess »

I'd start with 'strandtest', it's just about the easiest case. In fact the standard belt code is just this with a few extra bells & whistles added.

User avatar
slurry bowl
 
Posts: 156
Joined: Sun Nov 11, 2012 6:37 pm

Re: LPD8806 questions.....

Post by slurry bowl »

Well, Im making progress. Ive still got some abrupt changes, but Im learning alot.
Just to restate, I want to fade between, BLUE, MAGENTA, TURQUOISE.
This is the current code:

void loop() {
int r,g,b;
uint16_t i, j;

for (j=0; j < 40; j++) {
r = map(j, 0, 40, COLOR1_R, COLOR2_R);
g = map(j, 0, 40, COLOR1_G, COLOR2_G);
b = map(j, 0, 40, COLOR1_B, COLOR2_B);

for (i=0; i < 2; i++) {
strip.setPixelColor(i,(strip.Color(r,g,b) ));
}

strip.show(); // write all the pixels out
delay(100);
}

for (j=0; j < 40; j++) {
r = map(j, 0, 40, COLOR2_R, COLOR1_R);
g = map(j, 0, 40, COLOR2_G, COLOR1_G);
b = map(j, 0, 40, COLOR2_B, COLOR1_B);

for (i=0; i < 2; i++) {
strip.setPixelColor(i,(strip.Color(r,g,b) ));
}

strip.show(); // write all the pixels out
delay(100);

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

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”