Fix My Tilt (Simon Says) Game

  int arrayLength = 20;
  int tiltValues[arrayLength];
  int zeros = 0,ones = 0, twos = 0, threes = 0, fours = 0;
  for (int i=0; i < arrayLength; i++) { tiltValues[i] = getTilt(); delay(15); }
  for (int i=0; i < arrayLength; i++) {
    switch (tiltValues[i]) {
    case 0:
      zeros++;
      break;
    case 1:
      ones++;
      break;
    case 2:
      twos++;
      break;
    case 3:
      threes++;
      break;
    case 4:
      fours++;
      break;
    }
  }

There is no reason to store all the values in an array and then walk the array. Just increment zeros, ones, twos, threes, or fours, as each reading comes in.

This is my code responsible for reading out and smoothing the sensor values:

And the code that uses that data?

The array to filter out the fluctuations actually does its job.
My problem is with the 'return to neutral first' part.

It's useful to explain what the problem is. And, there is nothing in the code that I've seen that provides context for the 'return to neutral first' phrase.