I get the following message after compiling my code:
Sketch uses 10,296 bytes (31%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,826 bytes (89%) of dynamic memory, leaving 222 bytes for local variables. Maximum is 2,048 bytes.
Low memory available, stability problems may occur.
Is this "Low memory" a result of too many global variables? I could probably switch some of them to local variables, but would that help?
May help some.
Might be more helpful to put things that don't change into flash memory instead. Font definitions, messages to display on a screen, look up tables ...
Review your variable declarations also - all too often int is used when byte would do (value is <=255).
Moving them to local variables would help in most cases as they only use memory when actively used.
-
use local variables where possible
-
use smallest datatype possible
-
byte = 1 byte
-
int = 2 bytes
-
long/float = 4 bytes
-
if variables are const declare them as such,
-
move non changing vars esp. arrays to PROGMEM (as crossroads said)
-
shorten texts for "debug" messages
-
if possible replace an array with a formula or function
-
if possible compress large arrays (e.g. RunLength, folding, mirroring etc
-
changing the algorithm used for the project might also have an impact on the variables needed.
-
...
If you need a hand, post your code and we can give concrete advice for your case