int [20] accelDataArray; //your data
int accelDataCount = 0; //count number of readings
int prevTimer; //get time of last reading
int interval = 50; //50ms = 20Hz
void setup()
{NEWSLETTER
prevTimer = millis(); //get a starting point for millisecond count
}
void loop()NEWSLETTER
{
if(prevTimer >= prevTimer + interval) //using >= since it's possible 51 milliseconds can go by before this is reached
{
//read accelerometer
prevTimer = prevTimer + 50; //increment timer count
accelDataCount++; //increment the number of readings made
}
if(accelDataCount == 20) //we have made 20 readings which means array is full and one minute has passed
{
//write your data with time stamp
accelDataCount = 0;
}
//do other stuff
}
Is this kind of what your looking for? The only issue is that you may not get a reading at exactly 50ms intervals, but you should be relatively close. If your looking for super accurate intervals then using an interrupt would be the best way to go. One way you could achieve this would be hooking up an eternal pulse generator to an interrupt capable pin that is running at 20Hz.