view history edit print login register

Memory

There are three pools of memory in the microcontrollers used on Arduino boards (e.g. the ATmega168):

  • Flash memory (program space), is where the Arduino sketch is stored.
  • SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs.
  • EEPROM is memory space that programmers can use to store long-term information.

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:

 ATMega168ATMega328PATmega1280
Flash
(1 Kbyte used
for bootloader)
16 KBytes32 KBytes128 KBytes
SRAM1024 bytes2048 bytes8 KBytes
EEPROM512 bytes1024 bytes4 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.