#include <FastLED.h>
#define NUM_LEDS_RING 24
CRGB ring[NUM_LEDS_RING];
#define NUM_LEDS_PEBBLE 50
CRGB pebble[NUM_LEDS_PEBBLE];
void setup()
{
FastLED.addLeds<NEOPIXEL,9>(ring, NUM_LEDS_RING);
FastLED.addLeds<NEOPIXEL,10>(pebble, NUM_LEDS_PEBBLE);
}
void loop()
{
for (int i = 0; i < NUM_LEDS_PEBBLE; i++) {
pebble[i] = CRGB::Blue;
}
for (int i = 0; i < NUM_LEDS_RING; i++) {
ring[i] = CRGB::Blue;
}
for(int i = 0; i < NUM_LEDS_RING*2; i++) {
if (i%2 == 0) {
ring[i/2] = CRGB::Red;
}
pebble[i] = CRGB::Red;
FastLED.show();
delay(100);
}
}
I have the above code on an Adafruit Flora, with two sets of lights connected. If both sets of lights are powered, after an amount of time the program freezes until I disconnect the power from one of the lights, where after a few seconds it then starts back up again. I've had similar happen with the Neopixel library as well.
I'm guessing this is a memory issue but I'm not sure how to go about fixing it - I'm not familiar with C++, which means I've been struggling to work out what to search for and getting a lot of information on memory management that seems to not be applicable to a basic set of loops. Where should I be looking? Is it something like I need to be deleting the memory allocation for the variables used in the loops each time?