Average Analog Sensor Readings as an Array

Hello I have been trying to measure the average of 10 values at a time that my analog sensor on my arduino uno is reading. My goal is to have it read 10 values and average them and then that triggers a digital port (which I have working correctly). The code I have below stores it as an array but in the Serial Monitor it does not change the values at all in the array at all it just outputs the same numbers.

const int numReadings = 10;

int readings[numReadings]; // the readings from the analog input
int Array[numReadings];
int total = 0; // the running total
int average; // the average

void setup() {
analogReference(INTERNAL); //Sets voltage from (0- 1.1V)
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

for (int i=0; i < numReadings; i++){
Array[i] = analogRead(A0);
delay(500);
}
}
void loop() {

for (int i; i < numReadings; i++){
total = total + Array[i];
}
// calculate the average:
average = total / numReadings;
Serial.print(" Average A0: ");
Serial.println(average);
}

Oops.

Please remember to use code tags when posting code

Is putting the readings into an array serving some purpose, perhaps just an exercise? You can average them by adding them up as you read them, then when you get 10, divide by 10.

That is because you collect the data once in setup(), then average the data in loop(), over and over again. But there are other problems, as noted.

Move the data collection down into the loop() function.

Given that you never re-zero total, that's surprising.
I guess because of what I already posted, the for loop simply isn't executing.

I figured this would be the easiest way to get the average without doing a running average. I did an array of 10 values and calculated the average and then if that value is greater than some number then trigger the port. Then I wanted to loop that.

But you fill the array in setup, and that won't get executed again until you reset

I moved it down and I am still getting the same issue

So post the new code.
In code tags.

sebnil/Moving-Avarage-Filter--Arduino-Library-: A moving average, also called rolling average, rolling mean or running average, is a type of finite impulse response filter (FIR) used to analyze a set of datum points by creating a series of averages of different subsets of the full data set. (github.com)

I moved it down to the loop and I am still getting a string of the same values. Are you saying to write a line of code that resets the total ?

I can't see your code

const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int Array[numReadings];
int total = 0;                  // the running total
int average;                // the average

void setup() {
  analogReference(INTERNAL); //Sets voltage from (0- 1.1V)
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

}
// the loop routine runs over and over again forever:
void loop() {
  
  for (int i=0; i < numReadings; i++){
    Array[i] = analogRead(A0);
    delay(500);
  }
  for (int i; i < numReadings; i++){
  total = total + Array[i];
}
  // calculate the average:
  average = total / numReadings;
  Serial.print(" Average A0: ");
  Serial.println(average);
}

Still oops

const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int Array[numReadings];
int total = 0;                  // the running total
int average;                // the average

void setup() {
  analogReference(INTERNAL); //Sets voltage from (0- 1.1V)
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

}
// the loop routine runs over and over again forever:
void loop() {
  
  for (int i; i < numReadings; i++){
    Array[i] = analogRead(A0);
    delay(500);
  }
  for (int i; i < numReadings; i++){
  total = total + Array[i];
}
  // calculate the average:
  average = total / numReadings;
  Serial.print(" Average A0: ");
  Serial.println(average);
}
void loop() {
  static unsigned long sum;
  static int index;

  sum -= Array [index];
  sum += Array [index++] = analogRead(A0);
  if (index >= numReadings )
    index = 0;
  average = sum / numReadings;
  Serial.print(" Rolling average A0: ");
  Serial.println(average);
}

Double oops

Whoops I did the opposite. I will try with the edit then I will try with the code you posted thank you!

Your code still doesn't zero total.

const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int Array[numReadings];
int total = 0;                  // the running total
int average;                // the average

void setup() {
  analogReference(INTERNAL); //Sets voltage from (0- 1.1V)
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

}
// the loop routine runs over and over again forever:
void loop() {
  
  for (int i=0; i < numReadings; i++){
    Array[i] = analogRead(A0);
    delay(500);
  }
  for (int i=0; i < numReadings; i++){
  total = total + Array[i];
}
  // calculate the average:
  average = total / numReadings;
  Serial.print(" Average A0: ");
  Serial.println(average);
}

I tried this it still did not work and I was advised a smoothing function would be more effective. (I am hesitant to switch methods now until I figure this out