Adafruit NeoPixel y dos animaciones al mismo tiempo..?

Hola a todos, como están?

Le cuento que tengo 2 ring leds HW-159 de 7 leds cada uno. El primero quiero que este con una animación por ejemplo rainbow con una velocidad de 500ms y el segundo al mismo tiempo con (por ejemplo) theaterChaseRainbow en 900ms y no logro que funcionen bien.

Este es mi diagrama:

El código es de este mismo foro de un usuario que pidió ayuda para no usar delay();. Lo fui modificando y luego de muchas pruebas esta desprolijo, pido disculpas de antemano pero prefiero subir lo que tengo antes que nada.

#define PINforControl   3 // pin connected to the small NeoPixels strip
#define NUMPIXELS1      7 // number of LEDs on second strip
#define PINforControl2   5
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS1, PINforControl, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(NUMPIXELS1, PINforControl2, NEO_GRB + NEO_KHZ800);

unsigned long patternInterval = 20 ; // time between steps in the pattern
unsigned long lastUpdate = 0 ; // for millis() when last update occoured
unsigned long lastUpdate2 = 0 ;
unsigned long intervals [] = { 20, 20, 50, 100 } ; // speed for each pattern
const byte button = 2; // pin to connect button switch to between pin and ground

void setup() {
  strip.begin(); // This initializes the NeoPixel library.
  strip2.begin(); 
  wipe(); // wipes the LED buffers
  pinMode(button, INPUT_PULLUP); // change pattern button
}

void loop() {
  static int pattern = 0, lastReading;
  int reading = digitalRead(button);
  if(lastReading == HIGH && reading == LOW){
    pattern++ ; // change pattern number
    if(pattern > 3) pattern = 0; // wrap round if too big
    patternInterval = intervals[pattern]; // set speed for this pattern
    wipe(); // clear out the buffer 
    delay(50); // debounce delay
  }
  lastReading = reading; // save for next time

if(millis() - lastUpdate > patternInterval) updatePattern(pattern);
if(millis() - lastUpdate2 > patternInterval2) updatePattern(pattern2);
}

void  updatePattern(int pat){ // call the pattern currently being created
  switch(pat) {
    case 0:
        rainbow(); 
        rainbow2();
        //colorWipe2(strip2.Color(255, 0, 0)); // red
        break;
    case 1: 
        rainbowCycle();
        colorWipe2(strip2.Color(0, 200, 0)); // red
        break;
    case 2:
        theaterChaseRainbow(); 
        colorWipe2(strip2.Color(0, 0, 200)); // red
        break;
    case 3:
         colorWipe(strip.Color(255, 0, 0)); // red
         colorWipe2(strip2.Color(110, 110, 110)); // red
         break;     
  }  
}

void rainbow() { // modified from Adafruit example to make it a state machine
  static uint16_t j=0;
    for(int i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
     j++;
  if(j >= 256) j=0;
  lastUpdate = millis(); // time for next change to the display
  
}
//
void rainbow2() { // modified from Adafruit example to make it a state machine
  static uint16_t j=0;
    for(int i=0; i<strip2.numPixels(); i++) {
      strip2.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip2.show();
     j++;
  if(j >= 256) j=0;
  lastUpdate2 = millis(); // time for next change to the display
  
}

//
void rainbowCycle() { // modified from Adafruit example to make it a state machine
  static uint16_t j=0;
    for(int i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
  j++;
  if(j >= 256*5) j=0;
  lastUpdate = millis(); // time for next change to the display
}

void theaterChaseRainbow() { // modified from Adafruit example to make it a state machine
  static int j=0, q = 0;
  static boolean on = true;
  // for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
  //  for (int q=0; q < 3; q++) {
     if(on){
            for (int i=0; i < strip.numPixels(); i=i+3) {
                strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
             }
     }
      else {
           for (int i=0; i < strip.numPixels(); i=i+3) {
               strip.setPixelColor(i+q, 0);        //turn every third pixel off
                 }
      }
     on = !on; // toggel pixelse on or off for next time
      strip.show(); // display
      q++; // update the q variable
      if(q >=3 ){ // if it overflows reset it and update the J variable
        q=0;
        j++;
        if(j >= 256) j = 0;
      }
  lastUpdate = millis(); // time for next change to the display    
}

void colorWipe(uint32_t c) { // modified from Adafruit example to make it a state machine
  static int i =0;
    strip.setPixelColor(i, c);
    strip.show();
  i++;
  if(i >= strip.numPixels()){
    i = 0;
    wipe(); // blank out strip
  }
  lastUpdate = millis(); // time for next change to the display
}

void colorWipe2(uint32_t c) { // modified from Adafruit example to make it a state machine
  static int i =0;
    strip2.setPixelColor(i, c);
    strip2.show();
  i++;
  if(i >= strip2.numPixels()){
    i = 0;
    //wipe2(); // blank out strip
  }
  //lastUpdate2 = millis(); // time for next change to the display
}

void wipe(){ // clear all LEDs
     for(int i=0;i<strip.numPixels();i++){
       strip.setPixelColor(i, strip.Color(0,0,0)); 
       }
}

void wipe2(){ // clear all LEDs
     for(int i=0;i<strip2.numPixels();i++){
       strip2.setPixelColor(i, strip2.Color(0,0,0)); 
       }
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

uint32_t Wheel2(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip2.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip2.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip2.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Toda recomendación será agradecida!
Si alguien tiene un código mejor, también es bienvenido.
Gracias!

Ese esquema no tiene mucha relación con el código.
Las conexiones no coinciden.
Además, ¿Qué tiene que ver el DFplayer y los otros 2 botones?

El esquema es el correcto para mi proyecto. Lo subí porque lo piden las reglas del foro donde hay dos anillos conectados a x pines de arduino. El dfplayer es para que cuando la animación 1 inicie reproduzca un sonido. Si molesta mucho la elimino. No me pareció tan importante. El transformador lo agregué por una cuestión lógica, si molesta lo elimino y seguimos con el código.

Bueno, uno de los dos está equivocado.

En el código se trabaja con 1 botón en el pin 2, y 2 anillos en pines 3 y 5.
En el esquema hay 3 botones en pines 4, 5 y 6, y los anillos en pines 3 y 9.

Entonces ese código nunca va a funcionar bien con esas conexiones.
No hay botón en pin 2 ni anillo en pin 5.
¿Estamos de acuerdo?

Por lo demás está todo perfectamente presentado, tanto esquema como código. Muy bien por eso.
Lo que te digo es que el código no es compatible con el esquema (aunque no estuviese el reproductor).
¿Me explico?

Entiendo por eso mas abajo aclare que si había un código que se amolde a lo requerido era bienvenido y que el código había sido modificado varias veces en base a pruebas.

Voy a poner un código limpio para que no te haga ruido (como se dice en la jerga) y así nos centrarnos especificamente en que dos animaciones con distintos tiempos esten funcionando al mismo tiempo:

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#ifdef ESP32
// Cannot use 6 as output for ESP. Pins 6-11 are connected to SPI flash. Use 16 instead.
#define LED_PIN    3
#else
#define LED_PIN    3
#endif

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 7

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

unsigned long pixelPrevious = 0;        // Previous Pixel Millis
unsigned long patternPrevious = 0;      // Previous Pattern Millis
int           patternCurrent = 0;       // Current Pattern Number
int           patternInterval = 5000;   // Pattern Interval (ms)
int           pixelInterval = 50;       // Pixel Interval (ms)
int           pixelQueue = 0;           // Pattern Pixel Queue
int           pixelCycle = 0;           // Pattern Pixel Cycle
uint16_t      pixelCurrent = 0;         // Pattern Current Pixel Number
uint16_t      pixelNumber = LED_COUNT;  // Total Number of Pixels

// setup() function -- runs once at startup --------------------------------
void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}

// loop() function -- runs repeatedly as long as board is on ---------------
void loop() {
  unsigned long currentMillis = millis();                     //  Update current time
  if((currentMillis - patternPrevious) >= patternInterval) {  //  Check for expired time
    patternPrevious = currentMillis;
    patternCurrent++;                                         //  Advance to next pattern
    if(patternCurrent >= 7)
      patternCurrent = 0;
  }
  
  if(currentMillis - pixelPrevious >= pixelInterval) {        //  Check for expired time
    pixelPrevious = currentMillis;                            //  Run current frame
    switch (patternCurrent) {
      case 7:
        theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
        break;
      case 6:
        rainbow(10); // Flowing rainbow cycle along the whole strip
        break;     
      case 5:
        theaterChase(strip.Color(0, 0, 127), 50); // Blue
        break;
      case 4:
        theaterChase(strip.Color(127, 0, 0), 50); // Red
        break;
      case 3:
        theaterChase(strip.Color(127, 127, 127), 50); // White
        break;
      case 2:
        colorWipe(strip.Color(0, 0, 255), 50); // Blue
        break;
      case 1:
        colorWipe(strip.Color(0, 255, 0), 50); // Green
        break;        
      default:
        colorWipe(strip.Color(255, 0, 0), 50); // Red
        break;
    }
  }
}

void colorWipe(uint32_t color, int wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   //  Update delay time
  strip.setPixelColor(pixelCurrent, color); //  Set pixel's color (in RAM)
  strip.show();                             //  Update strip to match
  pixelCurrent++;                           //  Advance current pixel
  if(pixelCurrent >= pixelNumber)           //  Loop the pattern from the first LED
    pixelCurrent = 0;
}

void theaterChase(uint32_t color, int wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   //  Update delay time
  for(int i = 0; i < pixelNumber; i++) {
    strip.setPixelColor(i + pixelQueue, color); //  Set pixel's color (in RAM)
  }
  strip.show();                             //  Update strip to match
  for(int i=0; i < pixelNumber; i+=3) {
    strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); //  Set pixel's color (in RAM)
  }
  pixelQueue++;                             //  Advance current pixel
  if(pixelQueue >= 3)
    pixelQueue = 0;                         //  Loop the pattern from the first LED
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(uint8_t wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   
  for(uint16_t i=0; i < pixelNumber; i++) {
    strip.setPixelColor(i, Wheel((i + pixelCycle) & 255)); //  Update delay time  
  }
  strip.show();                             //  Update strip to match
  pixelCycle++;                             //  Advance current cycle
  if(pixelCycle >= 256)
    pixelCycle = 0;                         //  Loop the cycle back to the begining
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   //  Update delay time  
  for(int i=0; i < pixelNumber; i+=3) {
    strip.setPixelColor(i + pixelQueue, Wheel((i + pixelCycle) % 255)); //  Update delay time  
  }
  strip.show();
  for(int i=0; i < pixelNumber; i+=3) {
    strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); //  Update delay time  
  }      
  pixelQueue++;                           //  Advance current queue  
  pixelCycle++;                           //  Advance current cycle
  if(pixelQueue >= 3)
    pixelQueue = 0;                       //  Loop
  if(pixelCycle >= 256)
    pixelCycle = 0;                       //  Loop
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Aclaro nuevamente que es un codigo original de Adafruit pero es lo que necesito en principio ya que esta programado sin la funcion delay(), fue reemplazado con millis(), ahora solo restaría correr dos efectos al mismo tiempo sin importar cual, yo lo adapto. La idea es poder tener dos efectos pero con distinto tiempo cada efecto.

Aclaro también que el nuevo diagrama (el cual no subo porque estoy en mi trabajo) son dos ring de 7 leds, uno al pin 3 y otro al 5.

Gracias de antemano.

Lo solucione!

Por si a alguien mas le sirve les dejo el código. En si es hacer funcionar dos aros led a distinto tiempo o tipo de animación uno de otro.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif


#define LED_PIN1    3
#define LED_PIN2    5

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 7

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip1(LED_COUNT, LED_PIN1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2(LED_COUNT, LED_PIN2, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

unsigned long pixelPrevious = 0;        // Previous Pixel Millis
unsigned long patternPrevious = 0;      // Previous Pattern Millis
int           patternCurrent = 0;       // Current Pattern Number
int           patternInterval = 5000;   // Pattern Interval (ms)
int           pixelInterval = 50;       // Pixel Interval (ms)
int           pixelQueue = 0;           // Pattern Pixel Queue
int           pixelCycle = 0;           // Pattern Pixel Cycle
uint16_t      pixelCurrent = 0;         // Pattern Current Pixel Number
uint16_t      pixelNumber = LED_COUNT;  // Total Number of Pixels

/////////////////////////////////////////////////////////////////////////////
unsigned long pixelPrevious2 = 0;        // Previous Pixel Millis
unsigned long patternPrevious2 = 0;      // Previous Pattern Millis
int           patternCurrent2 = 0;       // Current Pattern Number
int           patternInterval2 = 5000;   // Pattern Interval (ms)
int           pixelInterval2 = 50;       // Pixel Interval (ms)
int           pixelQueue2 = 0;           // Pattern Pixel Queue
int           pixelCycle2 = 0;           // Pattern Pixel Cycle
uint16_t      pixelCurrent2 = 0;         // Pattern Current Pixel Number
uint16_t      pixelNumber2 = LED_COUNT;  // Total Number of Pixels
/////////////////////////////////////////////////////////////////////////////


// setup() function -- runs once at startup --------------------------------
void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  strip1.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip1.show();            // Turn OFF all pixels ASAP
  strip1.setBrightness(100); // Set BRIGHTNESS to about 1/5 (max = 255)

  strip2.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip2.show();            // Turn OFF all pixels ASAP
  strip2.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}

// loop() function -- runs repeatedly as long as board is on ---------------
void loop() {
  unsigned long currentMillis = millis();                     //  Update current time
  
  if((currentMillis - patternPrevious) >= patternInterval) {  //  Check for expired time
    patternPrevious = currentMillis;
    patternCurrent++;                                         //  Advance to next pattern
    if(patternCurrent >=2)//<<<<>>>>------------------------------------------------------------------>>>><<<<
      patternCurrent = 0;
  }

  if(currentMillis - pixelPrevious >= pixelInterval) {        //  Check for expired time
    pixelPrevious = currentMillis;                            //  Run current frame    

    //theaterChaseRainbow(50);
    switch (patternCurrent) {
      case 7:
        theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
        break;
      case 6:
        rainbow(10); // Flowing rainbow cycle along the whole strip
        break;     
      case 5:
        theaterChase(strip1.Color(0, 0, 127), 50); // Blue
        break;
      case 4:
        theaterChase(strip1.Color(127, 0, 0), 50); // Red
        break;
      case 3:
        theaterChase(strip1.Color(127, 127, 127), 50); // White
        break;
      case 2:
        colorWipe(strip1.Color(0, 0, 255), 50); // Blue
        break;
      case 1:
        //colorWipe(strip1.Color(0, 255, 0), 50); // Green
        theaterChase(strip1.Color(255, 30, 0), 100);
        break;        
      default:
        //colorWipe(strip1.Color(255, 0, 0), 50); // Red
        theaterChase(strip1.Color(200, 20, 0), 70);
        break;
    }
  }

    unsigned long currentMillis2 = millis();
  if((currentMillis2 - patternPrevious2) >= patternInterval2) {  //  Check for expired time
    patternPrevious2 = currentMillis2;
    patternCurrent2++;                                         //  Advance to next pattern
    if(patternCurrent2 >=0)//<<<<>>>>------------------------------------------------------------------>>>><<<<
      patternCurrent2 = 0;
  }

  if(currentMillis2 - pixelPrevious2 >= pixelInterval2) {        //  Check for expired time
    pixelPrevious2 = currentMillis2;                            //  Run current frame   
    //Si presiono el boton 

    colorWipe2(strip2.Color(0, 255, 0), 250); // Green 
    //theaterChase2(strip2.Color(127, 127, 127), 150); // White
    //rainbow2(5);
    //theaterChase2(strip2.Color(  255, 30, 0), 120);
    //theaterChase2(strip2.Color(  255, 30, 0), 100);
    //theaterChaseRainbow2(80);
  }   
    
}

// Some functions of our own for creating animated effects -----------------

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   //  Update delay time
  strip1.setPixelColor(pixelCurrent, color); //  Set pixel's color (in RAM)
  strip1.show();                             //  Update strip to match
  pixelCurrent++;                           //  Advance current pixel
  if(pixelCurrent >= pixelNumber)           //  Loop the pattern from the first LED
    pixelCurrent = 0;
}

void colorWipe2(uint32_t color2, int wait2) {
  Serial.println("s");
  if(pixelInterval2 != wait2)
    pixelInterval2 = wait2;                   //  Update delay time
  strip2.setPixelColor(pixelCurrent2, color2); //  Set pixel's color (in RAM)
  strip2.show();                             //  Update strip to match
  pixelCurrent2++;                           //  Advance current pixel
  if(pixelCurrent2 >= pixelNumber2)           //  Loop the pattern from the first LED
    pixelCurrent2 = 0;
}


// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
// between frames.
void theaterChase(uint32_t color, int wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   //  Update delay time  
  for(int i=0; i < pixelNumber; i+=3) {
    strip1.setPixelColor(i + pixelQueue, color); //  Update delay time  
  }
  strip1.show();
  for(int i=0; i < pixelNumber; i+=3) {
    strip1.setPixelColor(i + pixelQueue, strip1.Color(0, 0, 0)); //  Update delay time  
  }      
  pixelQueue++;                           //  Advance current queue  
  pixelCycle++;                           //  Advance current cycle
  if(pixelQueue >= 3)
    pixelQueue = 0;                       //  Loop
  if(pixelCycle >= 256)
    pixelCycle = 0;                       //  Loop                      //  Loop
}

void theaterChase2(uint32_t color2, int wait2) {
  if(pixelInterval2 != wait2)
    pixelInterval2 = wait2;                   //  Update delay time  
  for(int i=0; i < pixelNumber2; i+=3) {
    strip2.setPixelColor(i + pixelQueue2, color2); //  Update delay time   
  }
  strip2.show();
  for(int i=0; i < pixelNumber2; i+=3) {
    strip2.setPixelColor(i + pixelQueue2, strip2.Color(0, 0, 0)); //  Update delay time  
  }      
  pixelQueue2++;                           //  Advance current queue  
  pixelCycle2++;                           //  Advance current cycle
  if(pixelQueue2 >= 3)
    pixelQueue2 = 0;                       //  Loop
  if(pixelCycle2 >= 256)
    pixelCycle2 = 0;                       //  Loop
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(uint8_t wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   
  for(uint16_t i=0; i < pixelNumber; i++) {
    strip1.setPixelColor(i, Wheel((i + pixelCycle) & 255)); //  Update delay time  
  }
  strip1.show();                             //  Update strip to match
  pixelCycle++;                             //  Advance current cycle
  if(pixelCycle >= 256)
    pixelCycle = 0;                         //  Loop the cycle back to the begining
}

void rainbow2(uint8_t wait2) {
  if(pixelInterval2 != wait2)
    pixelInterval2 = wait2;                   
  for(uint16_t i=0; i < pixelNumber2; i++) {
    strip2.setPixelColor(i, Wheel2((i + pixelCycle2) & 255)); //  Update delay time  
  }
  strip2.show();                             //  Update strip to match
  pixelCycle2++;                             //  Advance current cycle
  if(pixelCycle2 >= 256)
    pixelCycle2 = 0;                         //  Loop the cycle back to the begining
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  if(pixelInterval != wait)
    pixelInterval = wait;                   //  Update delay time  
  for(int i=0; i < pixelNumber; i+=3) {
    strip1.setPixelColor(i + pixelQueue, Wheel2((i + pixelCycle) % 255)); //  Update delay time  
  }
  strip1.show();
  for(int i=0; i < pixelNumber; i+=3) {
    strip1.setPixelColor(i + pixelQueue, strip1.Color(0, 0, 0)); //  Update delay time  
  }      
  pixelQueue++;                           //  Advance current queue  
  pixelCycle++;                           //  Advance current cycle
  if(pixelQueue >= 3)
    pixelQueue = 0;                       //  Loop
  if(pixelCycle >= 256)
    pixelCycle = 0;                       //  Loop                      //  Loop
}

void theaterChaseRainbow2(int wait2) {
  if(pixelInterval2 != wait2)
    pixelInterval2 = wait2;                   //  Update delay time  
  for(int i=0; i < pixelNumber2; i+=3) {
    //strip2.setPixelColor(i + pixelQueue2, color2); //  Update delay time  
    strip2.setPixelColor(i + pixelQueue2, Wheel2((i + pixelCycle2) % 255)); //  Update delay time  
  }
  strip2.show();
  for(int i=0; i < pixelNumber2; i+=3) {
    strip2.setPixelColor(i + pixelQueue2, strip2.Color(0, 0, 0)); //  Update delay time  
  }      
  pixelQueue2++;                           //  Advance current queue  
  pixelCycle2++;                           //  Advance current cycle
  if(pixelQueue2 >= 3)
    pixelQueue2 = 0;                       //  Loop
  if(pixelCycle2 >= 256)
    pixelCycle2 = 0;                       //  Loop
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip1.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip1.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip1.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

uint32_t Wheel2(byte WheelPos2) {
  WheelPos2 = 255 - WheelPos2;
  if(WheelPos2 < 85) {
    return strip2.Color(255 - WheelPos2 * 3, 0, WheelPos2 * 3);
  }
  if(WheelPos2 < 170) {
    WheelPos2 -= 85;
    return strip2.Color(0, WheelPos2 * 3, 255 - WheelPos2 * 3);
  }
  WheelPos2 -= 170;
  return strip2.Color(WheelPos2 * 3, 255 - WheelPos2 * 3, 0);
}

Seguramente hay mejores maneras de hacerlo, mas prolijas etc. pero por ahora esta funcional 100%. Luego me dedicare a hacer todo desde funciones únicas. También quiero aclarar que en este código que comparto esta corregido el error en la función theaterChase(); que por algún motivo Adafruit descuido en el archivo de ejemplo "standtest_nodelay.ino".

Espero ayude a alguien. Saludos!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.