Lights setup eventually freezes - unsure how or what is causing what i suspect is dynamic memory issues

#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?

How are you powering the LEDs? Sounds more like an overheating voltage regulator.

1 Like

It's freezing while I've connected it to my PC via microusb - the lights have their power cables linked to the flora, the two strips are connected to separate 3.3V connectors. Normally I'd be using a phone powerbank with microusb to power it.

realised my description may not be very clear so here's a diagram as best as i can do of how things are connected

Edit: Having done some investigating and checking with my multimeter I can confirm the issue is the voltage/amps. Got too many lights on for the amps the board can put out. Thank you for the pointer!

The 3.3V flora connectors?

Neopixel strips normally need 5V, and 24+50=74 pixels could need up to 60mA*74=4.4A

Maybe move their power lines to the VBAT pin.

1 Like