The Arduino board’s are mostly limited to 1K of RAM (1000 bytes!!!) with a few Mega boards going up to 16K.. This made me appreciates today’s PC’s that can accommodate/consume Gigabytes of RAM.
Take for instance a PC with 4GB of ram. That’s about your average PC I would say. Compare that to a Arduino’s tiny 1K of memory.
That 4G equates to the RAM on 4’000’000 Arduino boars combined… Mind boggling!!!
What I found is that the first step to free RAM is to make sure it is not consumed by printing information to your serial port.
Normally you will go:
Serial.println(“Test info to print on the screen… “); // This could consume 3.5% of your ram alone!!!
Instead use the following:
Serial.println(F(“Test info to print on the screen… “)); // This uses Zero memory because as soon as its printed the memory gets cleared.
There are limitations. This does not work for numbers or variables. Only for constant lengths of char arrays. (Text in quotes)