Trying to understand the Multiple LED Array aspect of FastLED and looking at the

Trying to understand the Multiple LED Array aspect of FastLED and looking at the multiarrays.ino file. While I understand that particular code, being very basic, I am trying to undertsand when you want something a little more complex… and how it would be formatted.

As an example, if I wanted one strip to be an array running the Fire2012.ino file and a second array (on a second strip) running the ColorPalette.ino file, how that gets formatted. Since each .ino file has unique characteristics, am stumbling on how those get meshed into a single file.

Note: Unless, of course, I am misunderstanding the purpose behind multiple arrays… that it is only to vary a single routine rather than run two completely different routines.

Is there any links that I might review to see how two (or more) files get formatted into multiple arrays… aside from turning on/off?

Thank you

You can keep everything on one array. The trick is in how you populate the array with data that will be sent to the leds when you call LEDS.show().

Say you have two strips of 50 pixels each. Your main array for LEDs would be this: NUM_LEDS = 100. In computer code your LEDs would be numbered 0-99.

For the first animation, say you want the fire code to be on LEDs 0-49, so when you populate the array with LED data from the animation function it may look something like this:
for(int i= 0; i <49; i++){ }

The other animation would populate the array like this:
for(int i = 49; i < NUM_LEDS-1; i++) { }

It is important to note that when you call LEDS.show() it will push all the leds array data to the LED strip. This is why you should probably run both animation function s before calling the show function.

So… I’m slowly building and fleshing out an “LED suit” that will have a 12x12 grid on the chest and 6x12 grids on each shin, thigh, forearm, and bicep.

I’ve been wondering whether to wire it as one long 720 WS2812 LED strip or break it down into 9 separate grids.

If I understand the above correctly, I can wire it all as one strip but have “virtual grids” via arrays?

Would it would be faster getting data to LEDs with separate pins for each of nine grids, or would the difference be negligible compared to nine arrays off of one pin (currently from a Mega 2560, but possibly switching to a Due)?

Thanks Jon, for some reason I have been unable to get my noggin around running two animations off the same array…

Trying to understand the multiple array part, running two animations off two separate data pins… basically, combining two sketches into one.

I have been able to combine two sketches but trying to understand the code structure. Trying to make a ‘template’ sketch so I can refer to later on.

On the combined sketch, trying to understand the loop. It has a scan(); and a void scan () as part of the first animation. Should it also have a breathe(); and void breathe () as part of the second animation?

Whenever I keep tinkering around, I just get errors…

(need to get a Github account, sorry)

/*
This is an attempt at combining two individual sketches into one sketch, operating on two pins - 6 and 8
On pin 6, it runs a scanner animation that a set of leds travel back and forth, allowing you to define color, speed and trail length.
On pin 8, it runs an animation that fades between two colors, aloowing you to define colors and speed of transition.

Pin 6 runs an abbreviated and modified sketch that started life as juggle.ino by Mark Kriegsman… and later modified by Andrew Tuline
For additional information on the original sketches, they can be found on their specific GitHub pages:
Mark Kriegsman: kriegsman (Mark Kriegsman) · GitHub
Andrew Tuline: GitHub - atuline/FastLED-Demos: Here's my updated FastLED demos from January, 2017.

Pin 8 runs a modified sketch that started life as test_breath_effect_v2.ino by Marc Miller
For additional information on the original sketches, they can be found on his specific GitHub page:
Marc Miller: marmilicious (Marc Miller) · GitHub
*/

#include “FastLED.h”

// Fixed definitions cannot change on the fly.
#define DATA_PIN_A 6 // Data pin to connect to the strip.
#define DATA_PIN_B 8 // Data pin to connect to the strip.
#define LED_TYPE WS2811 // Style of led strip
#define COLOR_ORDER GRB // Color order of leds
#define NUM_LEDS_A 30 // How many leds are in the first strip’s animation
#define NUM_LEDS_B 30 // How many leds are in the second strip’s animation

// Initialize changeable global variables.
CRGB scanner[NUM_LEDS_A]; // Initialize led array for first animation
CRGB breather[NUM_LEDS_B]; // Initialize led array for second animation

//First Animation ‘scanner’
// Routine specific variables
uint8_t numdots = 1; // Number of dots in use.
uint8_t faderate = 35; // How long should the trails be. Very low value = longer trails.
uint8_t hueinc = 8; // Incremental change in hue between each dot.
uint8_t thishue = 80; // Starting hue - Change number based on ‘rainbow’ HSV value 0=red, 205=purple, etc.
uint8_t curhue = 0; // The current hue
uint8_t thissat = 255; // Saturation of the colour.
uint8_t thisbright = 255; // How bright should the LED/display be.
uint8_t basebeat = 13; // Higher = faster movement.

//Second Animation ‘breather’
// Routine specific variables
static float pulseSpeed = 1;// Larger value gives faster pulse.
uint8_t hueA = 96; // Start hue at valueMin.
uint8_t satA = 255; // Start saturation at valueMin.
float valueMin = 100.0; // Pulse minimum value (Should be less then valueMax).
uint8_t hueB = 80; // End hue at valueMax.
uint8_t satB = 255; // End saturation at valueMax.
float valueMax = 180.0; // Pulse maximum value (Should be larger then valueMin).
uint8_t hue = hueA; // Do Not Edit
uint8_t sat = satA; // Do Not Edit
float val = valueMin; // Do Not Edit
uint8_t hueDelta = hueA - hueB;// Do Not Edit
static float delta = (valueMax - valueMin) / 2.35040238; // Do Not Edit

//setup, called once - where the magic starts to happen
void setup() {

delay(1000); // Power-up safety delay or something like that.
Serial.begin(57600);

LEDS.addLeds<LED_TYPE, DATA_PIN_A, COLOR_ORDER>(scanner, NUM_LEDS_A);// Identifies which data pin the array NUM_LEDS_A is attach to
LEDS.addLeds<LED_TYPE, DATA_PIN_B, COLOR_ORDER>(breather, NUM_LEDS_B);// Identifies which data pin the array NUM_LEDS_B is attach to
}

//loop, runs over and over
void loop() {

/*
This is the code for the first animation
*/
for(int i = 0; i < NUM_LEDS_A; i++) { // This is saying I want the first animation on the pin that has NUM_LEDS_A
scan();
}
}

void scan() { // Several colored dots, weaving in and out of sync with each other
curhue = thishue; // Reset the hue values.
fadeToBlackBy(scanner, NUM_LEDS_A, faderate);
for( int i = 0; i < numdots; i++) {
scanner[beatsin16(basebeat+i+numdots,0,NUM_LEDS_A)] += CHSV(curhue, thissat, thisbright);//beat16 is a FastLED 3.1 function
curhue += hueinc;
}
/*
End of code for the first animation
*/

/*
This is the code for the second animation
*/
for(int i = 0; i < NUM_LEDS_B; i++) {// This is saying I want the first animation on the pin that has NUM_LEDS_B

float dV = ((exp(sin(pulseSpeed * millis()/2000.0PI)) -0.36787944) * delta);
val = valueMin + dV;
hue = map(val, valueMin, valueMax, hueA, hueB); // Map hue based on current val
sat = map(val, valueMin, valueMax, satA, satB); // Map sat based on current val
breather[i] = CHSV(hue, sat, val);
}
/

End of code for second animation
*/

FastLED.show(); //Sends above loop code out to the led strips
//loop starts all over again
}