URGENT: Global Variables Using Too Much Dynamic Memory

Hello everyone,

I would be more than glad if you guys can help me out ASAP for this problem of mine:

For a project, I am using FASTLed, Wire, and LiquidCrystal_I2C libraries. My code is not yet complete, yet the global variables are already using too much dynamic memory. At first, "Global variables use[d] (92%) of dynamic memory. Low memory available, stability problems may occur.", and the part I coded functioned perfectly. Then, I proceeded to type my code in, and when I checked if everything is OK, it said "Global variables use 2037 bytes (99%) of dynamic memory. Low memory available, stability problems may occur.", and although it said "Done Uploading", the part that worked perfectly before did not work along with everything else. As I proceed even more, the code cannot be uploaded to Arduino because it because usage of global variables exceeds the limit (2048 bytes). I am using Arduino UNO.

can't you use PROGMEM for some of your arrays? (and why are those arrays declared and initialized at every spin of the loop() as local scoped variables ??)

using a UNO with 471 RGB LEDs is looking for memory trouble anyway --> get a more capable arduino (a mega or a ESP32 for example)

The arrays don't seem to be taking up that much memory (as least as far as the compiler is concerned, since only a few are actually being used at the moment), the 471 LEDs take the bulk of the memory, each LED appears to need 3 bytes, so that is 1423 bytes total. You can save a small amount of dynamic ram by changing the lcd.print("text") statements to lcd.print(F("text")), which stores the text in program memory.

david_2018:
The arrays don't seem to be taking up that much memory (as least as far as the compiler is concerned, since only a few are actually being used at the moment), the 471 LEDs take the bulk of the memory, each LED appears to need 3 bytes, so that is 1423 bytes total. You can save a small amount of dynamic ram by changing the lcd.print("text") statements to lcd.print(F("text")), which stores the text in program memory.

Thanks for the advice, apparently the arrays were the problem though. Instead of arrays, I used complicated for functions, and it saved me quite a bit of bytes.

Removing the code from the first post is breaking the rules here. Put it back so the rest of the comments make sense.

Also adding your solution would help others.

Instead of arrays, I used complicated for functions, and it saved me quite a bit of bytes.

On the face of things this sounds like rubbish, almost as if you don't understand how to use arrays.