int VSI_Alt = 0;
int VSIvalue = 0;
unsigned long VSI_LastTime = 0;
//Averiging
// first remove (subtract) the oldest valeu from ArraySum
VSIArraySum -= VSIArray[VSIArrayIndex];
// ... and replace it with the new value
VSI_Alt = AltitudeArraySum / AltitudeArraySize;
VSI_LastTime = millis();
VSIArrayIndex +=1; // shift the index for next time
if (VSIArrayIndex == VSIArraySize) { // if we reached the tom of the array
VSIArrayIndex = 0; //go to the start of the array
}