WS2812b custom function not looping

Hi,
Im kinda new to LED strips and bought some online. I then installed a library (Adafruit Neopixel) and adressing one LED strip worked perfectly fine.
Since i have mulitple LED strips in my room, i wanted to be able to adress them individually and customize the example functions for easier control.
My idea was to add another transfer Value (the strip that should get adressed).
Kinda like this:

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PINcomputer      8
#define NUMcomputer      78

#define PINwindow        9
#define NUMwindow        55

Adafruit_NeoPixel computer = Adafruit_NeoPixel(NUMcomputer, PINcomputer, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel window = Adafruit_NeoPixel(NUMwindow, PINwindow, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second

void setup() {
  window.begin();
  computer.begin();
  computer.show();
  window.show();
  window.setBrightness(20);
  computer.setBrightness(30); 
}

void loop() {
  theaterChase(window, window.Color(255,0,0),300);
}


void theaterChase(Adafruit_NeoPixel strip, uint32_t c, uint8_t wait) {  //Here's the change
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

uint32_t Color(byte r, byte g, byte b)
{
  uint32_t c;
  c = r;
  c <<= 8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}

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

However when i run the code above, the window strip does the theaterChase, but it doesnt loop.
It does it like 10 times but then stands still. When i run the original example code it works perfectly fine.
So the basic idea of transfering the window instance of the strip class is working, but there seems to be an error somewhere that i cant find.
Thank for the help in advance!
Greetings Crocs

Unless you want to run the theaterChase() 1st for the computer strip, and after that for the window strip this cant work...
you have here a function which does a bunch of loops for one strip, and while running inside this function the other strip is dead (or better: stays at its last programmed pattern).
So if you want to run both strips simultanously but still with the same animation you can do two things:
either modify theaterChase() so that you dont pass in the strips, but just control them both within that function like that:

      for (int i=0; i < computer.numPixels(); i=i+3) {
        computer.setPixelColor(i+q, c);    //turn every third pixel on
      }
      computer.show();
      for (int i=0; i < window.numPixels(); i=i+3) {
        computer.setPixelColor(i+q, c);    //turn every third pixel on
      }
      window.show();

but then it makes not much sense to separately control them at all ...
the other option is to just make one strip out of the two with connecting DOUT of 1st strip to DIN of 2nd strip ...

another option might be using FastLED - from this library is known that it can handle multiple strips, and it comes even with samples for that ...

Alright thank you very much for the reply!
Ill give this library a try then...
I dont really wanna connect them since the final project would be to controll each strip individually via an app for android. The main function will be to let the strips react to some music via FHT.
Thanks for the help i appreciate it!

I've read that many projects which use multiple strips with FastLED then use a Teensy; while the Teensy 2.0 might be close to the same as a Leonardo Pro Micro, the higher Teensy versions have different chips ...
if you just want to control these two strips independantly then I'd suggest you get 2 cheap Arduino Nano clones which cost less than one Teensy ...

Crocs:
I dont really wanna connect them since the final project would be to controll each strip individually via an app for android.

You can connect them together and still control each strip separately, as long as you connect the end of one strip to the start of the other (its best to take 5V and ground separately to both strips, however). It's all in the programming. The program can update leds 0 to 77 with one pattern and 78 to 127 with another pattern. You don't need Teensy 3 or multiple Nano to do this.

Paul

PaulRB:
It's all in the programming.

Exactly - and that's the point: not everyone is able or wants to learn how to clever code around limitations of a library like the Adafruit Neopixel. This library comes with only 3 samples, and only one sample shows some nice pixel animations for one strip ...
many folks come here and want to put some things together and then just use them with existing libraries + existing sketches, and for that task the Adafruit Neopixel library is not the best candidate since AFAIK it does not work with interrupts well (or even not at all). Then there exists the FastLED library which comes with a bunch of builtin animations + support for multiple strips with ARM-based hardware (probably FastLED does also support multiple strips fine with ATMega328-based hardware - I've not used yet, and did not check - I leave that to the OP), though no RGBW support yet ...
So for me the bottom line is: unless I want to re-invent the wheel and code an own clever new library where my main goal is to learn coding, I just use what's already available; and if that requires to buy some other cheap hardware then this is ok for me if I want to get the strips animating independently before the end of the year ... :slight_smile:

So for me the bottom line is: unless I want to re-invent the wheel and code an own clever new library where my main goal is to learn coding, I just use what's already available; and if that requires to buy some other cheap hardware then this is ok for me if I want to get the strips animating independently before the end of the year

This is so sad.
If you can't reinvent the wheel then you will never be able to invent anything.
Using a state machine is not fancy library code. There is no need to invent more libraries there are already too many of them.
You have been told how to get strips animating independently without any state machine and yet your mind is closed.
As I said this is very sad for you but don't assume everyone wants to be at your level.

MegaFan:
how to clever code around limitations of a library like the Adafruit Neopixel.

There are no limitations on the Adafruit Neopixel library that are not present in the FastLED library. So the only difference in this respect is that maybe the FastLED library has some more comprehensive examples.

We pride ourselves here in giving good advice, please try and uphold this tradition if you are going to offer advice especially to newcomers.

FastLEDs multiple controller output works on AVRs, too.

But there the strips are written one after the other, on ARMs its timewise parallel.

If high fps rates are not required, an Arduino Uno is fine for driving several strips showing different animations.

1st apologies if my English is bad but its not my maiden's language.

Grumpy_Mike:
This is so sad.
If you can't reinvent the wheel then you will never be able to invent anything.

I wrote "want" and not "can't", and to my English knowledge this is something different.

Grumpy_Mike:
You have been told how to get strips animating independently without any state machine and yet your mind is closed.

really? Where I have been told? And where have I even asked for??

Grumpy_Mike:
As I said this is very sad for you but don't assume everyone wants to be at your level.

And where do I assume about others?

Grumpy_Mike:
We pride ourselves here in giving good advice, please try and uphold this tradition if you are going to offer advice especially to newcomers.

I thought I tried - my apologies if I failed.
But from you I only see that you personally attack me without reason instead of helping the OP;
since you seem to know well about coding and the Adafruit Neopixel library, why dont you write quickly an example which shows the newcomer and me how easy it is to run two independent strips with some different animations? I'm sure that many others would be happy too for such a sample, and that would even be something to offer in a new topic ...

an example which shows the newcomer and me how easy it is to run two independent strips with some different animations

Here you go. 2 animations on one strip.

And here are all the informations needed to run multiple strips.

Questions, anyone?

Hi Helmut,

Helmuth:
Here you go. 2 animations on one strip.

And here are all the informations needed to run multiple strips.

Questions, anyone?

That's FastLED, and not Adafruit Neopixel based - so exactly what I said before:
FastLED is known to be able to handle multiple strips

But thanks for quickly providing the link, and thanks for checking that it works with AVRs too.

I wrote "want" and not "can't", and to my English knowledge this is something different.

Yes it is sad that this is what you want.

And where do I assume about others?

You are giving advice to the OP, he is another, that is where you assume.

But from you I only see that you personally attack me without reason instead of helping the OP;

No attack, I was saying that your attitude made me sad, I was not saying it made me angry which would be an attack.

since you seem to know well about coding and the Adafruit Neopixel library, why dont you write quickly an example which shows the newcomer and me how easy it is to run two independent strips with some different animations? I'm sure that many others would be happy too for such a sample, and that would even be something to offer in a new topic

Yes I can do that but it will have to be next week as my reel of Neopixels is in another location so I won't be able to access it until the weekend. But it is just like a state machine nothing fancy.
See my
http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html
Or Robin2's several things at once
http://forum.arduino.cc/index.php?topic=223286.0
The thing is you do not use delay or the for loop, each stage of your animation is a state number.