Data collection using ADXL335 accelerometer

Hi,

How can I use the adxl335 accelerometer to collect data for about 20 seconds at a sampling rate of 1Khz?

I am getting the data from the accelerometer. I just don't know how to collect data for 20 seconds since the analogRead() is in a loop.

I just don’t know how to collect data for 20 seconds since the analogRead() is in a loop.

You need to use millis() to time the collection period.

Have a look at Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE.

Save the millis() value before starting data collection then check each time through the data collection loop, which could use the loop() function, whether the required period has passed.