Is there a limit to how many different pins I can use on an

Is there a limit to how many different pins I can use on an Arduino Mega 2560 to drive WS2812b LEDS using the current FASTLED library?

I want to re-wire my Xmas tree such that each branch (34 branches total) is wired separately and I do not have to daisy-chain them. Note also that each branch would have any number of LEDs, based on length, ranging from 4 (min) to 12 (max) for a total of around 300 LEDS . Do you see any potential problems with this project ?

The biggest concern is that it will balloon your code size, because right now the templates instantiate on pin, not port, so I’d say try it out first by compiling and uploading and making sure you have the flash.

Alternatively, look into a due - same form factor, more flash/ram (and the possibility of parallel output :slight_smile:

Hi Daniel,

Great idea… I just now quickly did it with a modified, working sketch of Fire2012 (it was working on an array of 6X25 array of WS2812b on 6 different pins).

Including the actual ‘fire’ code, I created a 32X12 array on 32 different pins of my MEGA2560 and the thing compiled and loaded ok in just under 49 Kb !!

#define NUM_STRIPS 32
#define NUM_LEDS_PER_STRIP 12

CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];

FastLED.addLeds<NEOPIXEL, 22>(leds[0], NUM_LEDS_PER_STRIP);
FastLED.addLeds<NEOPIXEL, 23>(leds[1], NUM_LEDS_PER_STRIP);

etc… etc…

FastLED.addLeds<NEOPIXEL, 52>(leds[30], NUM_LEDS_PER_STRIP);
FastLED.addLeds<NEOPIXEL, 53>(leds[31], NUM_LEDS_PER_STRIP);

Is that less than what you were expecting !?

Note that I did not yet connect any LEDS… that’s coming…

Hi again @Daniel_Garcia , just now did a very quick test with jumper wires from each of the 32 pins used in my 32X12 array sketch and I can see that each of the 32 pins pump 12 LEDs worth of fire animation data !!

I am only guessing that they are indeed 32 totally distinct, unique animations and that I have a working solution for my tree now !!

Very, very impressed with that FASTLED Library !!!

Hello @Daniel_Garcia , me again on the same subject… :wink:

As mentioned, I was able to verify that I can have a 32X12 array of LEDs (384) driven out of 32 different pins of a MEGA 2560 with the FASTLED library. The code running a FIRE2012 style animation compiled to less than 49Kb so I’m happy with that.
However, I actually only have a total of 304 WS2812b in my Xmas tree such that the largest branch has 12 LEDS, some branches 11, 10, etc… and the smallest branch only has 5 LEDS. I want to minimise the amount of data sent such that I can achieve the best FPS rate with my Arduino MEGA.

If I used the following…
#define NUM_STRIPS 32
#define MAX_NUM_LEDS_PER_STRIP 12
CRGB leds[NUM_STRIPS][MAX_NUM_LEDS_PER_STRIP];

void setup() {
FastLED.addLeds<NEOPIXEL, 22>(leds[0], NUM_LEDS_BRANCH_1);
FastLED.addLeds<NEOPIXEL, 23>(leds[1], NUM_LEDS_BRANCH_2);

etc… etc…

FastLED.addLeds<NEOPIXEL, 52>(leds[30], NUM_LEDS_BRANCH_31);
FastLED.addLeds<NEOPIXEL, 53>(leds[31], NUM_LEDS_BRANCH_32);
}

Would… FastLED.show();
Only send 304 LED worth of data or the whole leds array of 384 ?

It will only send the 304 LEDs worth of data.

Thanks, @Daniel_Garcia I apologise for harassing you on the same subject but I am about to start assembling a power and data distribution scheme for my Xmas tree and want to ensure I select the best design before I start soldering everything.

I would expect that the time required to send data to 304 LEDS via 32 different pins to a number of LEDs ranging from 5 (min) to 12 (max) per pin is similar to the time taken to send that data via a single pin to 304 LEDs that are daisy-chained ?

Can you confirm that ?
Can you quantify the difference if any ?

Thanks again !

It will end up taking longer than if they were in one chain because there will be time spent at the beginning/end of each chain for a variety of work that’s outside the raw pushing of LED data. I don’t know offhand how much extra overhead it would be - you’d have to measure that. I’d imagine it wouldn’t be more than a couple microseconds per line.

Thanks Daniel,

Unfortunately I do not have access to a scope or logic analyser so it is not easy to take actual timing measurements.

But your suggestion of a few microseconds between pins aligns with my expectations also so I will (finally) proceed with the multi-pin approach.

Thank you very much, I hope to post a few pictures / videos of my tree soon !!

Shift registers?

Adam, it is unclear what you are trying to say - are you asking a question? Making a suggestion? Initiating a word association game?

Daniel ,yes a question.It is possible to drive an endless amount of leds (rgb analog) with shift registers , thus I was curious would one not be able to do the same with digital led strips perhaps? Then not having to worry about running out of pwm pins on arduino.

No, digital strips like the ws2812 are already shift registers internally.

(And in fact you aren’t using pwm pins to drive strips like the ws2812 or apa102)

Thank you , I am fairly new to coding and the little knowledge I have , led me to believe that it was pwm , dunno what I was thinking :\