I'm initializing my strips as an array:

// Declare NeoPixel strip array:
Adafruit_NeoPixel strip[] = {
  Adafruit_NeoPixel(LED_COUNT[0], LED_PIN[0], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(LED_COUNT[1], LED_PIN[1], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(LED_COUNT[2], LED_PIN[2], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(LED_COUNT[3], LED_PIN[3], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(LED_COUNT[4], LED_PIN[4], NEO_RGBW + NEO_KHZ800)

and when I pass Color to a function, I'm arbitrarily using my first strip to create the Color:

  everyother( strip[0].Color( 0, 255, 0), strip[0].Color( 255, 0, 0), 500);

but in the subroutine I use those colors to set pixels to every strip of the array in a loop:

// set every other color to color1 or color2
void everyother( uint32_t color1, uint32_t color2, int wait) {
  for(int k=0; k<NUM_STRIPS; k++) {
    for( int j=0; j<LED_COUNT[k]; j++) {
      if( j%2 == 0) strip[k].setPixelColor(j, color1);
      else strip[k].setPixelColor(j, color2);
  for(int k=0; k<NUM_STRIPS; k++) strip[k].show();  

Is there another way to define Color that isn't using a real Adafruit_NeoPixel? Yes, it works this way but it feels sloppy.

1 Answer 1


Looking at the library at https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h, you can see that the Color method is static (see line 307):

static uint32_t   Color(uint8_t r, uint8_t g, uint8_t b) {
  return ((uint32_t)r << 16) | ((uint32_t)g <<  8) | b;

This means instead of

strip[0].Color( 0, 255, 0)

You can use:

Adafruit_NeoPixel::Color( 0, 255, 0)

Your call to everyother will be:

everyother(Adafruit_NeoPixel::Color( 0, 255, 0),
           Adafruit_NeoPixel::Color( 255, 0, 0), 

And since everyother is now not a good name, you can think of a better one, e.g. fillLeds (always start a method name with a verb).


  • A subroutine is barely used anymore, I think the last time I heard it, is from the Basic programming language
  • A function is now used instead
  • But when a function is inside a class, it's not called a function, but called method.
  • 1
    Thanks for the response. I knew it was gonna be something simple that I was missing. And thanks for the tips. If you need help writing assembly for a VAX, hit me up. Nov 12, 2020 at 1:34
  • 1
    @JohnnyRollerfeet ... you're welcome... I don't have a VAX at hand lol, but in case I see one, I know who to call. Now I also know why you used the term subroutine. Good luck with your project. Nov 12, 2020 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.