0

I built a LED Matrix with ws2812b LEDs. It is driven by an arduino nano. I use the CLED lib in combination with FastLED. It works fine!

Now I have a very simple routine here that wont work although there is no error or warning.

The problem seems to be the array which is a path of LEDs I want to activate. So what am I missing? When I activate this on the arduino it freezes. The getRandomColorValue() function simply returns a color value 0-255. that one works like a charm.

int outlinePath[] = {30, 31, 29, 28, 27, 26, 26, 42, 43, 44, 45, 46, 25, 9, 8, 0, 1, 2, 4, 3, 16, 17, 56, 57, 91, 92, 101, 102, 111, 112, 121, 122, 162, 192, 193, 229, 230, 262, 263, 274, 275, 276,   277, 270, 269, 254, 239, 240, 241, 242, 243, 244, 253, 252, 251, 250, 249, 211, 210, 176, 177, 178, 179, 175, 161, 152, 151, 142, 141, 132, 131, 77, 72, 73, 74, 75, 76, 37, 31};
FastLED.clear();

for (int i = 0; i < 70; i++) {
    int test = outlinePath[i];
    leds.m_LED[test] = CRGB(getRandomColorValue(), getRandomColorValue(), getRandomColorValue());
}

FastLED.show();
delay(1000);

And this one works very well:

void progFastBlingBling() {
    FastLED.clear();
    leds.m_LED[random(0, anz_LEDs)] = CRGB(getRandomColorValue(), getRandomColorValue(), getRandomColorValue());
    FastLED.show();
}
ggorlen
  • 44,755
  • 7
  • 76
  • 106
just4phil
  • 25
  • 1
  • 5
  • What is `anz_LEDs` value? – Eraklon Feb 22 '20 at 22:07
  • 2
    Maybe memory issues. If you really have over 278 LEDs, that means almost 900B ram, and that outlinePath is another 142B of memory. Add some String concatenations and crash is imminent – KIIV Feb 22 '20 at 22:27
  • hey...that is only the total number of LEDs – just4phil Feb 22 '20 at 23:52
  • hm .... but it only fails if i insert the TEST variable. this does NOT fail: leds.m_LED[i] = ....... althought the array is still there (..ok maybe the compiler deletes it because it is unused....) – just4phil Feb 22 '20 at 23:57
  • function deactivated: IDE says total size: 105191 – just4phil Feb 23 '20 at 00:00
  • function activated: IDE says total size: 104253 – just4phil Feb 23 '20 at 00:01
  • 1
    The Arduino Nano uses the AVR ATmega328P. This device has only 2KiB SRAM. The difference of your values are 938 Bytes. That's nearly the half of the entire SRAM. –  Feb 23 '20 at 03:09
  • well it seems to be a memory issue. if i reduce the array to 10 values evrything works fine :( – just4phil Feb 23 '20 at 15:38
  • i tried to switch the array into ProgMem like this: const static PROGMEM unsigned int outlinePath[] = {30, 31, ....., 76, 37, 31}; but now i get a very weird behaviour! when i iterate over the array i dont get my path. instead i get some random LEDs ?? what can cause this behaviour?? – just4phil Feb 23 '20 at 16:15

0 Answers0