Save data and send to serial port

Hello everyone.

Sorry for my noobish question, but I have a problem. For my very first work on arduino I’m trying to read values from an acceletometer. My next step is to save the data registered over few seconds and then send it to serial port.

I’ve read about the EEPROM but I have not a clear idea of what to do. This is my code so far.

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;

char report[80];

void setup()

void loop()

  snprintf(report, sizeof(report), "A: %6d %6d %6d    M: %6d %6d %6d",
    compass.a.x, compass.a.y, compass.a.z,
    compass.m.x, compass.m.y, compass.m.z);


What I should do to reach my objective?

Thanks in advance.

What I should do to reach my objective?

If your objective is to write to EEPROM, then, you should learn how to do that.

At 50+ bytes per record, you’ll only have room to store about 20 records in the 1024 bytes of EEPROM on a 328-based Arduino.

At 10 iterations of loop() per second, you’ll be able to collect about 2 seconds worth of data.

Once you have learned to write to EEPROM and read it back be very careful how often you do it because the EEPROM can only be used for a relatively small number of write and read cycles to each of its memory locations.

Are you sure that you need to write to the EEPROM ? Could you not send the data as it is read from the accelerometer ?

Thanks to both of you for your answers. After looking deeper in what you suggested I think it'll be better to send the data directly from the accelerometer, probably as an array.