I can do this by declaring each indiviual LED but I will be doing 10 different arrays of LEDs, each triggered progressively. However I have fallen at the first hurdle, I cannot get my for loop to run through my declared array (ARRAY) to show all of those specific LEDs.
Have tried a lot of variations but haven't managed so consulting the forum.
Many thanks in advance for any help
Ben
#include <FastLED.h>
#define LED_PIN 4
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define cellColour 255,0,0
const int Array[] = {25,28,106,110,125,146,164,169,180,227}; //This is the array I want to show on first scan
#define BRIGHTNESS 64
const uint8_t kMatrixWidth = 32;
const uint8_t kMatrixHeight = 8;
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
CRGB* const leds( leds_plus_safety_pixel + 1);
void setup() {
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
}
void loop() {
for(int i=(ARRAY); i<NUM_LEDS; i++)
{
leds[i].setRGB(cellColour); //basically this part here to run through the above array
delay(100);
FastLED.setBrightness( BRIGHTNESS );
FastLED.show();
}
}
your sketch would mostly make sense. But what do you intend to go to do with multiple arrays?
Also, that extra pixel for safety is unnecessary. If you use the library to write to the pixel array, it will simply not do so with LEDs beyond the end.
Yes, but you need to adjust the for loop limit to only be the size of the array you are stepping through, not NUM_LEDS.
I just counted the elements and used 10 in my examl,e above, there are better ways of automatically determining the number of elements in an array, so you don't need to count or worry when you add or remove elements.
When you are doing more like what you are experimenting now to prepare for, you may want to use 2 dimensional arrays instead of N 1 dimensional arrays.
If the numbers are small, and most of the groups are of similar size, there will be little waste just using a 2 dimensional array.
If the groups are larger and all over the place size wize, you may need to consider a more memory friendly data structure to hold that info.
OK thanks will check 2 dimensional arrays and see if it works for this project. Not 100% sure how I will do it yet but will likely post on here if I get really stuck.