 bool isRedButtonPressed;
 bool isGreenButtonPressed;
 bool isBlueButtonPressed;
+bool gameOver;
 
 const int sensor1pin = 8; // connect the first sensor to pin 8 on the Arduino Mega
 //const int sensor2pin = 8; // connect the first sensor to pin 8 on the Arduino Mega


void loop() 
{
  int time = millis();

  // constantly monitor the player's input for minimal delay
  checkPlayerInput();
  
  // create a new Dance Move at a regular interval
  if (time - createDanceMoveTimer > DANCE_MOVE_CREATE_INTERVAL)
    createDanceMove();
  
  // update the strip
  if (time - updateTimer > UPDATE_INTERVAL)
  {
    processPlayerInput();
    updateStrip();
  }
}
boolean isSteppedOn(long pressurePlateValue) {
  return ((pressurePlateValue > stepThreshholdRed) || 
          (pressurePlateValue > stepThreshholdGreen) || 
          (pressurePlateValue > stepThreshholdBlue));
}

int playNextNote(int noteDurations[], int melodyCounter, int melody[], int melodyLength) {
      // to calculate the note duration, take one second
      // divided by the note type.
      //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
      int noteDuration = 1000 / noteDurations[melodyCounter];
      tone(sensor1pin, melody[melodyCounter], noteDuration); 
  
      // to distinguish the notes, set a minimum time between them.
      // the note's duration + 30% seems to work well:
      int pauseBetweenNotes = noteDuration * 1.30;

      if (melodyCounter < melodyLength){
        melodyCounter++;
      }
      else {
        melodyCounter = 0;
      }
      
      return melodyCounter;
}

void incrementWhichSong() {

//const int sensor4pin = 8; // connect the first sensor to pin 8 on the Arduino Mega
//const int sensor5pin = 8; // connect the first sensor to pin 8 on the Arduino Mega

int allSongNotes[7][42] = {
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
              },
              {NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4, 0, 0, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
              }, 
              {NOTE_E4, NOTE_D4, NOTE_C4, NOTE_E4, NOTE_D4, NOTE_C4,
               NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4,
               NOTE_D4, NOTE_D4, NOTE_D4, NOTE_D4,
               NOTE_E4, NOTE_D4, NOTE_C4, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
               0, 0, 0, 0, 0, 0, 0
              },
              {NOTE_A4, NOTE_A4, NOTE_C5, NOTE_D5, NOTE_F5, NOTE_F5, NOTE_D5, 
               NOTE_C5, NOTE_C5, NOTE_D5, NOTE_C5,
               NOTE_A4, NOTE_A4, NOTE_C5, NOTE_D5, NOTE_F5, 
               NOTE_F5, NOTE_D5,
               NOTE_C5, NOTE_C5, NOTE_D5, NOTE_C5,
               NOTE_C5, NOTE_C5, NOTE_C5, NOTE_A4, NOTE_C5, 
               NOTE_D5, NOTE_D5, NOTE_C5, 
               NOTE_A4, NOTE_A4, NOTE_G4, NOTE_A4, NOTE_C5,
               NOTE_G4, NOTE_A4,
               NOTE_F4, NOTE_F4, NOTE_G4, NOTE_F4, 0
              },  
              {NOTE_C4, NOTE_C4, NOTE_G4, NOTE_G4, NOTE_A4, NOTE_A4, NOTE_G4,
               NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_D4,
               NOTE_D4, NOTE_C4, 
               NOTE_G4, NOTE_G4, NOTE_F4, NOTE_F4, NOTE_E4, 
               NOTE_E4, NOTE_D4,
               NOTE_G4, NOTE_G4, NOTE_F4, NOTE_F4, NOTE_E4,
               NOTE_E4, NOTE_D4,
               NOTE_C4, NOTE_C4, NOTE_G4, NOTE_G4, NOTE_A4,
               NOTE_A4, NOTE_G4,
               NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_D4, 
               NOTE_D4, NOTE_C4
              }, 
              {NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_C5, 
               NOTE_A4, NOTE_C5, NOTE_G4,
               NOTE_F4, NOTE_F4, NOTE_G4, NOTE_E4, NOTE_E4, 
               NOTE_D4, NOTE_D4, NOTE_E4, NOTE_C4,
               NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, 
               NOTE_C5,
               NOTE_A4, NOTE_C5, NOTE_G4,
               NOTE_C5, NOTE_A4, NOTE_G4, NOTE_G4, 
               NOTE_F4, NOTE_E4, NOTE_D4, NOTE_C4, 
               0, 0, 0, 0, 0, 0, 0
               }, 
              { NOTE_E5, NOTE_E5, NOTE_E5, NOTE_C5, NOTE_E5,
                NOTE_G5, NOTE_G4, 
                NOTE_C5, NOTE_G4, NOTE_E4, 
                NOTE_E4, NOTE_A4, NOTE_B4, NOTE_AS4, NOTE_A4, 
                  NOTE_G4, NOTE_E5, NOTE_G5, NOTE_A5, NOTE_F5, 
                NOTE_G5, 
                NOTE_E5, NOTE_C5, NOTE_D5, NOTE_B4, 
                  NOTE_C5, NOTE_G4, NOTE_E4, 
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
              } 
};


int allNoteDurations[7][42] = {
              {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
              },
              {4, 8, 8, 4, 4, 4, 4, 4,
               0, 0, 0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
              }, 
              {4, 4, 2, 4, 4, 2, 
                             8, 8, 8, 8, 8, 8, 8, 8, 
                             4, 4, 2,
               0, 0, 0, 0, 
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
               0, 0, 0, 0, 0, 0, 0
              },
              {4, 8, 8, 8, 8, 8, 8, 4, 8, 8, 2, 
               4, 8, 8, 8, 8, 8, 8, 4, 8, 8, 2, 
               4, 4, 4, 8, 8, 4, 4, 2, 
               4, 8, 8, 8, 8, 8, 8, 4, 8, 8, 2,
               0
              },  
              {4, 4, 4, 4, 4, 4, 2, 
                   4, 4, 4, 4, 4, 4, 2, 
               4, 4, 4, 4, 4, 4, 2,
               4, 4, 4, 4, 4, 4, 2,
               4, 4, 4, 4, 4, 4, 2,
               4, 4, 4, 4, 4, 4, 2
              }, 
              {8, 8, 8, 8, 4, 4, 
               4, 4, 2, 
               4, 8, 8, 4, 4, 
               4, 8, 8, 2, 
               8, 8, 8, 8, 4, 4, 
               4, 4, 2,
               4, 8, 8, 8, 4, 
               4, 4, 2,
               0, 0, 0, 0, 0, 0, 0
               }, 
              {8, 4, 4, 8, 4, 
               2, 2, 
               4, 2, 4, 
               8, 4, 4, 8, 4, 
               8, 8, 8, 4, 8, 8, 
               4, 8, 8, 2, 
               4, 4, 4,
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
              } 
};

int long stepThreshholdRed = 2400;
int long stepThreshholdGreen = 2500;
int long stepThreshholdBlue = 2400;

CapacitiveSensor   cs_green = CapacitiveSensor(4,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_red = CapacitiveSensor(13, 12);        // 10M resistor between pins 1 & 0, pin 0 is sensor pin, add a wire and or foil if desired
