Adafruit Neopixels

Hi all,

I tried posting this earlier but I'm not sure if it worked. I'm using some addressable neopixel sticks from adafruit. It seems as though to create a color variable you need to do the following:

uint32_t magenta = strip.Color(255,0,255);

But to me this means that if I want to set three different led sticks the same color, I need to create a variable for each of them:

uint32_t magenta1 = strip1.Color(255,0,255);
uint32_t magenta2 = strip2.Color(255,0,255);
uint32_t magenta3 = strip3.Color(255,0,255);

How can I create a color variable that I can use for all three strips?

Thanks,

Smiles

Hi. No you don't need to do that, as long as the strips are all the same type. If that's true, you will get the same answer for magenta from whichever strip's object you use.

Pa

probably even more simple would be to create some defines for the colors you want to use, like:

#define RED     0x00FF0000
#define GREEN   0x0000FF00
#define BLUE    0x000000FF
#define MAGENTA 0x00FF00FF

and then use these directly with setPixelColor() ...

also with current Adafruit Neopixel version you can directly use the single color values with setPixelColor() - take a look at Adafruit_NeoPixel.h which shows the calling conventions:

...
    setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
    setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
    setPixelColor(uint16_t n, uint32_t c),
...