Multiple WS2812B (Neopixel) strips, Different Lengths

Good evening all,

Pursuing quite a rigorous and code-intensive project right now, which may expand later should I decide to utilize the unused pins. I am setting up 5 mirrors, 2 pairs of the same size (small, medium), and a single large mirror, with 25(x2)/35(x2)/48(x1) WS2812B pixels on each mirror(Small[x2]/Medium[x2]/Large[x1]). I have made many attempts at manipulating the different examples for multiple strips and "array-within-array" (FastLED) code tactics to tackle this, but alas, I am at a loss.
The problem is that the code examples there define the number of pixels for all the strips to be the same variable (and, therefore, the same number), which I cannot do. Being that I have 3 lengths total, will I need to define 3 separate lengths for each size mirror and then setup 3 different types of mirrors, two of which would be an array-within-array style due to duplicate sizes?
Many thanks for the help, if you're interested in what purpose they will serve, they're just a decoration going in my room to fill an empty wall. Each mirror will have a PIR sensor on either side of it and when you pass by it will animate according to the locations that were broken. The default mode of display will have the RTC push the time in the form of a clock to the largest mirror (since it's 48 LEDs, it will roughly display which ~5 minute increment the time is closest to. Modes will be changeable via BT connection on the phone. Future possible inclusions: IR Receiver/Transmitter pair for controlling in-room electronics/appliances (TV, Cable, in-wall AC), wiring a 350MHz controller to 5 pins for controlling my fan/light.
Cheers :slight_smile:
Anselmo C.

Too much information.
You have three different lengths in a string.
There's a numpixel variable (Adafruit library) which is the number of pixels in a string.

pixels.setPixelColor(whichpixel, pixels.Color(0,0,0)); // dark
"whichpixel" can be a variable or a 'magic number' (a number not declared a variable) for the position to write to.

pixels.show();
makes it happen.

I appreciate your answer, however, I don't think that's going to solve my issue. I have already fiddled around with the adafruit libary for Neopixels, didn't quite work out.. Calling to any other strip and then pushing it to show would only light up the first strip. I would have to manually program every one of the 168 pixels that are divided into 5 LED strings, and there is a much simpler way of going about it than Adafruit's method of coding.. Thanks though.

Hoping someone with some FastLED knowledge/experience or someone who has gone through this can shed some light on what I'm dealing with.

Did you already read this?

You just need to define different CRGB arrays according to you different physical strip lengths and assign them to different strips.

Then just manipulate every single CRGB array in the way you like it and after calculating all arrays you send them all with one fastled.show().

An array of arrays (aka 2 dimensional array) makes no sense with different strip lenghts. It would only waste RAM.

For 3 strips the minimal code would look like

#include "FastLED.h"
#define NUM_LEDS_PART_A 25  
#define NUM_LEDS_PART_B 35
#define NUM_LEDS_PART_C 48

CRGB ledsA[NUM_LEDS_PART_A];
CRGB ledsB[NUM_LEDS_PART_B];
CRGB ledsC[NUM_LEDS_PART_C];

void setup() {
 FastLED.addLeds<NEOPIXEL, 10>(ledsA, NUM_LEDS_PART_A);
 FastLED.addLeds<NEOPIXEL, 11>(ledsB, NUM_LEDS_PART_B);
 FastLED.addLeds<NEOPIXEL, 12>(ledsC, NUM_LEDS_PART_C);
}

Next thing to read and understand: 2 animations at the same time.

Thank you so much, that's exactly what I've been trying to do. The thing is, the ones that have length of 35 and 25, I have 2 of those strips (e.g. 2x25 pixel and 2x35 pixel strips). Would it be okay to use the same variable for the number of pixels when I define those separate CRGB arrays? I would just have to call those separate strips whenever I want them to show?

Edit: That post at the bottom with "2 animations at the same time" is something I've been looking for too, I really appreciate that :slight_smile:

Sure, you can reuse the predefined length for different arrays like for an additional

CRGB ledsD[NUM_LEDS_PART_A];

Depending on your PIR sensor data you manipulate only one array and fill the others with solid black in case you want only one strip to light up.

All data stays in the arrays until you cange it.

Good luck with your project!

I can't thank you enough, Helmuth, I really appreciate your help!

Only control the length of the LED?Hope this can help to you!Application effect you can see it here!
https://www.facebook.com/photo.php?fbid=114936048869269&set=pb.100010586229917.-2207520000.1446777859.&type=3&theater

#include <Adafruit_NeoPixel.h>

#define PIN 6
#define MAX_LED 60

Adafruit_NeoPixel strip = Adafruit_NeoPixel( MAX_LED, PIN, NEO_RGB + NEO_KHZ800 );

void setup()
{
  strip.begin();                       
  strip.show();   
}

void loop()
{ 
   uint32_t color;
   uint8_t i,R,G,B;
   R=50;
   G=50;
   B=50;
   color= strip.Color(R,G,B);      //Change R,G,B numbers, realize different color ;
    for(i=0;i<40;i++)                //LED all numbers;
    {
     strip.setPixelColor(i,0);
    } 
    
   for(i=0;i<10;i++)                //control  LED  lit lengths;
   {
    strip.setPixelColor(i,color);  
   }
   strip.show(); 
   delay(500);
}

Does anybody know if its possible to have say a neopixel strip, each neopixel within that strip being controlled by a proximity/IR sensor?

Don't cross-post, you will get into trouble with the moderators. You have started your own thread, which is the best way.

I've ran into a problem and could use help please. This issue seems similar.

I'm running about 480 LEDS in my setup with a teensy 3.1 and octosw2811. I have 6 strips with different amount of leds . How do I define the amount of leds per strip. For example

Strip #1 num of leds is 61,
Strip #2 num of leds is 86,
Strip num 3 is 94,
Strip #4 num of leds is 86,
Strip #5 num of leds is 61,
Strip #6 num of leds is 94.

I didn't realize that the strips need to be parallel. I thought I could just set the # of leds vertically and horizontally like I did in Ambibox.

You should start your own thread for this, not hijack someone else's thread. The problem may sound similar to you, but your hardware sounds quite different.

Here is my code that has 41 neopixels on pin 8 and 120 neopixels on pin 3. Total LED count is 161.

It is running a modification of the juggle code.

// MultipleStripsInOneArray - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on
// using multiple controllers.  In this example, we're going to set up four NEOPIXEL strips on three
// different pins, each strip will be referring to a different part of the single led array

#include <FastLED.h>

#define NUM_LEDS_PER_STRIP_A 120
#define NUM_LEDS_PER_STRIP_B 41

#define NUM_LEDS 161

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, 3>(leds, 0, NUM_LEDS_PER_STRIP_A);

  FastLED.addLeds<NEOPIXEL, 8>(leds, 120, NUM_LEDS_PER_STRIP_B);

}

void loop() {

  fadeToBlackBy( leds, NUM_LEDS, 50);
  byte dothue = 108;
  for( int i = 0; i < 4; i++) {
    leds[beatsin16( i+1, 0, NUM_LEDS )] |= CHSV(dothue, 250, 150);
    dothue += 32;
  FastLED.show();  
  
  }
   
}