Generate large matrix, then store it in project memory instead of flash

I am making an LED strip flash through a rainbow, but it had to calculate the next value of the rainbow for red, blue, and green for every step. Now I made a for loop that can run in setup that generates a lookup table for all RGB values (IE, colors[LED][R/G/B] ) which DEFINITELY speeds it up.

However, it also brings the dynamic memory for the sketch up to 76%, and I have other plans as well. After the lookup table is generated, it wont be changed again. could I move it into project memory after it's generated?

Thanks!

you can use "progmem" for that.

https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

how do I go about this?

sherzaad: you can use "progmem" for that.

https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

Trevader24135: how do I go about this?

a bit or a round about way but this is how I would do it:

  • generate your lookup table and print to serial monitor: format printout as "data0,data1,data2, ...., dataN"

  • copy that string then paste it into your array in your new code: const dataType variableName[] PROGMEM = {data0,data1,data2, ...., dataN};

to use the data go thru the link I gave you already