unsigned long timeTime = 0, timeTenMin = 0; int timeInc = 1000, timeIncTen = 1000*60*10; // time between measurements & time between printing average int val = 0, counter = 0, temp = 0; const int listSize = (timeIncTen / timeInc), outSize = 144; // listSize changes to be as many small measurements as you can fit in the large timeperiod int valList[10000], outList[144]; int averageVal(){ // a function to get the average value of valList temp = 0; for (int i = 0; i < listSize; i++){ temp = temp + valList[i]; } return temp / listSize; } void setup() { // put your setup code here, to run once: Serial.begin(115200); delay(1000); Serial.print("Party Time, the list is "); Serial.print(listSize); Serial.println(" elements long"); // used in testing to tell if dynamic list lenght works pinMode(36, INPUT); // prep the sensor for (int i = 0; i < listSize; i++){ // declair values for the list valList[i] = 0; } } void loop() { // put your main code here, to run repeatedly: if (millis() > (timeTime + timeInc)){ // get a measurement, add to a list at the counter position, then advance the counter val = analogRead(36); valList[counter] = val; counter++; counter = counter % listSize; timeTime = timeTime + timeInc; } if (millis() > (timeTenMin + timeIncTen)){ // print the recent measurements for (int i = 0; i < outSize - 1; i++){ // move all values forward in the list outList[outSize - 1 - i] = outList[outSize - 2 - i]; } temp = averageVal(); outList[0] = temp; // first element of list to the measured average Serial.print("Recent measurements, taken every "); // then just print it all out Serial.print(timeIncTen); Serial.println(" milisecodnds:"); for (int i = 0; i < outSize; i++){ Serial.println(outList[outSize - 1 - i]); // print from last element to first so you can copy and paste into excel and have it be in the right order } timeTenMin = timeTenMin + timeIncTen; } }