There are three pools of memory in the microcontrollers used on Arduino boards (e.g. the ATmega168):
Flash memory and EEPROM memory are non-volatile (the information persists after the power is turned off). SRAM is volatile and will be lost when the power is cycled.
Note: Flash (PROGMEM) memory can only be populated at program burn time. You can’t change the values in the flash after the program has started running.
The amounts of memory for various microcontrollers used on Arduino boards are as follows:
(1 kByte used
|16 kBytes||32 kBytes||128 kBytes||256 kBytes|
|SRAM||1024 bytes||2048 bytes||8 kBytes||8 kBytes|
|EEPROM||512 bytes||1024 bytes||4 kBytes||4 kBytes|
One thing you will notice in the chart above is that there is a lot more Flash (program) memory than SRAM available. When you create variables with the Arduino language such as:
char message = "I support the Cape Wind project.";
You are copying 33 bytes (1 char = 1 byte, plus terminating null) from program memory into SRAM before using it. 33 bytes isn't a lot of memory in a pool of 1024 bytes, but if the sketch requires some large unchanging data structures - such as a large amount of text to send to a display, or a large lookup table, for example - using flash memory (program memory) directly for storage may be the only option. To do this, use the PROGMEM keyword.