#include int analogPin = 35; int num; int i,f,g; int total = 0, total1 = 0; void totalAverage(int i){ int j,totaverg=0; for(int j =0;j<=i;j++){ totaverg += EEPROM.read(j); } Serial.println(totaverg/(i+1)); } void showAverages(int i){ //This shows all the averages that have been collected so far int j; int totalAverage = 0; Serial.println("Start"); for(int j=0; j<=i;j++){ Serial.println(EEPROM.read(j)); delay(100); } Serial.println("End"); } void showTopAverages(int i){ //This prints out the top 5 averages collected so far int one,two,three,four,five,j,k; for(int j=0; j<=i;j++){ k = EEPROM.read(j); if(k>one){ five = four; four = three; three = two; two = one; one = k; } else if(k>two){ five = four; four = three; three = two; two = k; } else if(k>three){ five = four; four = three; three = k; } else if(k>four){ five = four; four = k; } else if(k>five){ five = k; } delay(100); } Serial.println("The top 5 average values are:"); delay(10); Serial.println(one); delay(10); Serial.println(two); delay(10); Serial.println(three); delay(10); Serial.println(four); delay(10); Serial.println(five); } void showBottomAverages(int i){ //This prints the lowest averages collected so far int one = INT_MAX,two=INT_MAX,three=INT_MAX,four=INT_MAX,five=INT_MAX,j,k; for(int j=0; j<=i;j++){ k = EEPROM.read(j); if(k0){ char command = Serial.read(); if (command == 'h'){ showTopAverages(i); } else if(command == 'l'){ showBottomAverages(i); } else if(command == 'a'){ showAverages(i); } else if(command == 't'){ totalAverage(i); } } } EEPROM.write(i, total/60); //CHANGE BACK TO 600!!!!!!!!!!!!!!! delay(100); EEPROM.commit(); delay(100); Serial.print(millis()/6000); Serial.println(" minutes have passed during this data collection"); f = 0; total = 0; } }