NeoPixel library for more than one stripe

the functions don't use strip2...

strip.Color(255, 0, 0) or strip2.Color(255, 0, 0) is just a color, it does not indicate which strip to use

in the function

void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

the use of strip in

    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match

is what indicates which strip to use.

you could pass the strip (by reference) to the function, for example

void colorWipe(Adafruit_NeoPixel& targetStrip, uint32_t color, int wait) {
  for(int i=0; i< targetStrip.numPixels(); i++) { // For each pixel in targetStrip...
    targetStrip.setPixelColor(i, color);          //  Set pixel's color (in RAM)
    targetStrip.show();                           //  Update strip to match
    delay(wait);                                  //  Pause for a moment
  }
}

and call it with

const uint32_t redColor = strip.Color(255,   0,   0);
colorWipe(strip,  redColor, 50); // Red for first strip
colorWipe(strip2, redColor, 50); // Red for second strip
1 Like