WS2812 working simultanius on 2 arduino ports with button

Hi there,

i have been working on this project for 2 full days now to get the understanding on what i can do with the ws2812 led strip. I am now stumbling on a problem i cannot figure out (lack of knowlegde).
This is what i want to accomplish:

I want for now to use two ws2812 ledstrips on two different ports of the arduino. Both doing a TheatreChase. Ledstrip A starts TheatrChase when i press a button (pressing the button just once starts the whole process...with the code i have now i must press the button after every Pattern). After about 4 seconds i want strip B to also start the TheatreChase. Strip A must do the TheatreChase continousely while Strip B needs to do the TheatreChase on the led's 0 till led 16. After 5 seconds it must turn on led 11 till 20 (while led 0-16 still does the TheatreChase) for about 3 seconds and turn it of again, then switch led 21 till 25 for about 5 seconds (while led 0-16 still does the TheatreChase) and then switch it off...

I hope this makes it clear on what i want to accive....My english is not perfect (i am Dutch)

I have been trying so many different things in the code, that i lost track of what i did and what i did not try...

I hope you can help me get this code finished....Here is what i have done till now....

#include <Adafruit_NeoPixel.h>

int buttonPin = 0;          // De knop zit op pin 0
int oldButtonVal = 0;

#define LEDCOUNT   50       // aantal LEDs in de strip
#define PINA 6              // pin nummer waar strip A data op zit
#define PINB 5              // pin nummer waar strip B data op zit
#define TPIXELA 29          //aantal leds op strip A
#define TPIXELB 16          //aantal leds op strip B

// DEFINITIES

// Parameter 3 = RGB LED vlaggen, combineer indien nodig:
// NEO_KHZ800  800 KHz bitstream (de meeste NeoPixel producten met WS2812 LEDs)
//   NEO_KHZ400  400 KHz (klassieke 'v1' (niet v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     RGB LED volgens GRB bitstream (de meeste NeoPixel produkten)
//   NEO_RGB     RGB LED volgens RGB bitstream (v1 FLORA pixels, niet v2)

Adafruit_NeoPixel strip_a = Adafruit_NeoPixel(TPIXELA, PINA, NEO_RGB + NEO_KHZ800);
Adafruit_NeoPixel strip_b = Adafruit_NeoPixel(TPIXELB, PINB, NEO_RGB + NEO_KHZ800);

int nPatterns = 4;
int lightPattern = 1;

// begin/initialisatie bij drukken knop of reset knop:
void setup() {
  strip_a.begin();
  strip_a.show();                   // initialisatie van alle LEDs op strip A (resulteert in UIT zetten hier)
  strip_b.begin();
  strip_b.show();                   // initialisatie van alle LEDs op strip B (resulteert in UIT zetten hier)

  pinMode(buttonPin, INPUT);      // initializeer de knop als input
  digitalWrite(buttonPin, HIGH);  // knop pin is HIGH, dus het veranderd naar 0 bij ingedrukt.
}


// Pattern 1 - White light, all LEDs in the strip are white
void pattern1() {
  // Zogenaamde theater chase voorbeeld ...
  theaterChase(strip_a.Color(255,   0,   0), 125);
} // Rood, parameter 1 = Kleurcode 255,0,0 Parameter 2 = snelheid van het looplicht

//Theatre-style kruipende LEDs.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int q=0; q < 3; q++) {
    for (int i=0; i < strip_a.numPixels(); i=i+3) {
      strip_a.setPixelColor(i+q, c);
    }  //zet elke 3de RGD LED aan
    strip_a.setBrightness(75);
    strip_a.show();
    delay(200);                      // tijd dat de led aan blijft en daarna door onderstaande code wordt uitgeschakeld
    for (int i=0; i < strip_a.numPixels(); i=i+3) {
      strip_a.setPixelColor(i+q, 0);     //zet elke 3de RGB LED uit
      strip_a.Color(0, 0, 0);
      strip_a.show();
    }
  }
}


// Pattern 2 - Red light, all LEDs in the strip are red
void pattern2() {
  // Zogenaamde theater chase voorbeeld ...
  theaterChase1(strip_b.Color(255,   150,   0), 125);
} // Rood, parameter 1 = Kleurcode 255,0,0 Parameter 2 = snelheid van het looplicht

//Theatre-style kruipende LEDs.
void theaterChase1(uint32_t c, uint8_t wait) {
  for (int q=0; q < 3; q++) {
    for (int i=0; i < strip_b.numPixels(); i=i+3) {
      strip_b.setPixelColor(i+q, c);
    }  //zet elke 3de RGD LED aan
    strip_b.setPixelColor(0, strip_b.Color(0, 255, 0)); // Red
    strip_b.setPixelColor(10, strip_b.Color(0, 255, 0));
    strip_b.setPixelColor(12, strip_b.Color(0, 255, 0));
    strip_b.setPixelColor(13, strip_b.Color(0, 255, 0));
    strip_b.setPixelColor(14, strip_b.Color(0, 255, 0));
    strip_b.setBrightness(75);
    strip_b.show();
    delay(200);                      // tijd dat de led aan blijft en daarna door onderstaande code wordt uitgeschakeld
    for (int i=0; i < strip_b.numPixels(); i=i+3) {
      strip_b.setPixelColor(i+q, 0);     //zet elke 3de RGB LED uit
    }
  }
}

// Pattern 3 - Orange light, all LEDs in the strip are orange
void pattern3() {
  strip_b.setPixelColor(0, strip_b.Color(255, 128, 0)); // Orange
  strip_b.setPixelColor(1, strip_b.Color(255, 128, 0));
  strip_b.setPixelColor(2, strip_b.Color(255, 128, 0));
  strip_b.setPixelColor(3, strip_b.Color(255, 128, 0));
  strip_b.setPixelColor(4, strip_b.Color(255, 128, 0));
  strip_b.show();
}

// Pattern 4 - Yellow light, all LEDs in the strip are yellow
void pattern4() {
  strip_a.setPixelColor(0, strip_a.Color(255, 255, 0)); // Yellow
  strip_a.setPixelColor(1, strip_a.Color(255, 255, 0));
  strip_a.setPixelColor(2, strip_a.Color(255, 255, 0));
  strip_a.setPixelColor(3, strip_a.Color(255, 255, 0));
  strip_a.setPixelColor(4, strip_a.Color(255, 255, 0));
  strip_a.show();
}

// the loop routine runs over and over again forever;
void loop() {
  // read that state of the pushbutton value;
  int buttonVal = digitalRead(buttonPin);
  if (buttonVal == LOW && oldButtonVal == HIGH) {// button has just been pressed
    lightPattern = lightPattern + 1;
  }
  if (lightPattern > nPatterns) lightPattern = 1;
  oldButtonVal = buttonVal;

  switch(lightPattern) {
  case 1:
    pattern1();
    break;
  case 2:
    pattern2();
    break;
  case 3:
    pattern3();
    break;
  case 4:
    pattern4();
    break;

  }
}

I hope you can help me get this code finished....Here is what i have done till now....

I can't even follow the code. NOTHING goes on the same line as the }.

Move ALL of your } to lines by themselves. Use Tools + Auto Format to properly indent your code. Try posting it again.

thanks for the tip...as i did not even know i could do this..hahah

code updated

code updated

Don't do THAT again, either. You are not paying for bandwidth. Post your modified code in the reply. Do NOT replace the initially posted code.

This:

void theaterChase(uint32_t c, uint8_t wait) {
  for (int q=0; q < 3; q++) {
    for (int i=0; i < strip_a.numPixels(); i=i+3) {
      strip_a.setPixelColor(i+q, c);
    }  //zet elke 3de RGD LED aan
    strip_a.setBrightness(75);
    strip_a.show();
    delay(200);                      // tijd dat de led aan blijft en daarna door onderstaande code wordt uitgeschakeld
    for (int i=0; i < strip_a.numPixels(); i=i+3) {
      strip_a.setPixelColor(i+q, 0);     //zet elke 3de RGB LED uit
      strip_a.Color(0, 0, 0);
      strip_a.show();
    }
  }
}

is a blocking function. When you call this function, the Arduino does nothing else until this function ends. You can's have two different versions of this function, for the two light strips, running simultaneously.

You need to read, understand, and embrace the blink without delay example's philosophy, and read up on state machines.

On any given pass through loop(), you decide whether it is time to change state (what a given strip is showing), and if so, what the new state should be. Then, if it is time to change state, you record when the state changed, and implement the state change.

Do the same for the other strip.