3

(coco) #1
FORGE

and processing capabilities. As a developer, you
must always pay attention to how you use the
device’s memory and processor.
An Arduino device has a limited amount of
three types of memory:



  • Flash Memory: Stores the Arduino bootloader
    and your compiled sketch.

  • Static RAM: Used for variable storage.

  • EEPROM (electrically erasable programmable
    read-only memory): Non-volatile memory you
    can use to store data while the Arduino is
    turned off.


The Arduino Uno, for example, has the
following memory footprint:



  • 256kB of flash memory

  • 2kB of static RAM

  • 1kB of EEPROM memory


When you compile your sketch, the compiler
will inform you of how much memory your sketch
consumes, as shown in Figure 3. As you code
larger and more complicated sketches, or use more


libraries in your sketches, you must pay attention
to this data in order to ensure that your sketch will
run as coded on your selected Arduino device. In
the example shown, we’re only using 14% of flash
memory (program storage space) and 17% of static
RAM (dynamic memory) for my sketch, so we’re in
good shape (for now).
Sketch uses 4780 bytes (14%) of program storage
space. Maximum is 32256 bytes.

Global variables use 352 bytes (17%) of dynamic
memory, leaving 1696 bytes for local variables.
Maximum is 2048 bytes.

If your sketch exceeds the available memory on
the device, you must either re-factor the application
to make better use of the memory available to
you, or switch to another device that provides
more memory.

Left
If you’re ever unsure
about exactly what a
variable type means,
you can check the
Arduino language
reference at
hsmag.cc/VYrTRY

Arduino devices are inexpensive programmable
microcontrollers, and in order to meet its
imposed cost limitation, the devices have limited
memory and processing capabilities


Free download pdf