# Simple question on arrays

Hello everyone,
I am trying to program an Arduino Uno to read the analog values of 2 different NTC thermistors connected with dividers and with the analog pins of the Arduino.

1. the Arduino takes 10 measurements with some delay between each other
2. store each measurement in a array
3. compare the first value stored in the array with the sum of the 10 values
4. if the sum is the same with the 1st value, print a message
5. when 10 measurements are completed, “clean” the array and go back to the beginning
``````#include <math.h>

int backLight = 13;    // pin 13 will control the backlight

void setup(void) {
Serial.begin(9600);
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.

}

double Temp;
Temp = log(((10240000 / RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp)); //calculations used for the thermistors
Temp = Temp - 273.15;           // Convert Kelvin to Celcius
return Temp;
}

void printTemp(void) {

Serial.print("\n");
Serial.print("Temperature is:");
Serial.print(temp);
Serial.print("\n");
Serial.print("Temperature2 is:");
Serial.print(temp2);
Serial.print(" C  ");
double  stemp = (temp + temp2) ;
Serial.print("\n");
Serial.print("SUM temperature is:");
Serial.print(stemp);
double stfump = (stemp / 2) ;
Serial.print("\n");
Serial.print("AVERAGE temperature of 2 sensors is:");
Serial.print(stfump);
Serial.print("\n");
Serial.print("\n");
delay(3000);
Serial.print(",,,,,,,,,,,,");

}

void loop(void) {
float reading = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float summer = 0;
float stfump = 0;

for ( int i = 0; i = 9; i++) {
printTemp();
delay(1);
}

if (summer == reading) { //checking whether the sum of the array is the same with the 1st value
Serial.print("completed measurement");
}
}
``````

Here is my code:

Any help is more than welcome,

Napster

``````for ( int i = 0; i = 9;
``````

Bzzzt

The stfump declared in printTemp()

``````  Serial.print(stemp);
double stfump = (stemp / 2) ;
Serial.print("\n");
``````

is not the same variable as the stfump declared in loop()

``````void loop(void) {
float reading = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float summer = 0;
float stfump = 0;
``````

The latter one will not be updated by the printTemp() function so will always have a value of zero.
So
`    reading[i] = stfump;`will always store zero in the array.

napster210:

1. the Arduino takes 10 measurements with some delay between each other
2. store each measurement in a array
3. compare the first value stored in the array with the sum of the 10 values

Unless all the measurements after the first one are zero, I don't see how the first value could ever equal the sum of all ten values.

What is unique about the "First" measurement that validates it as a comparison standard?. Better IMO to discard the outliers and average or smooth the rest.

Doc