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.
The amounts of memory for various microcontrollers used on Arduino boards are as follows:
| ATMega168 | ATMega328P | ATmega1280 | |
|---|---|---|---|
| Flash (1 Kbyte used for bootloader) | 16 KBytes | 32 KBytes | 128 KBytes |
| SRAM | 1024 bytes | 2048 bytes | 8 KBytes |
| EEPROM | 512 bytes | 1024 bytes | 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 putting 33 bytes (1 char = 1 byte, plus terminating null) into SRAM. 33 bytes isn't a lot of memory in a pool of 1024 bytes, but if the sketch requires some large 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) for storage may be the only option. To do this, use the PROGMEM keyword.
To use the EEPROM, see the EEPROM library.