   } else if (pressed(blueButton) && (state == statePlay)) {
     checkPressing(blueLed, NOTE_F4, blueButton);
   }
-
+  */
+
+}
+
+void computeButtonStates(int index, int button, int led) {
+      int tmpVal = analogRead(button);
+      delay(20);
+      if (tmpVal > 900) {
+        buttonStates[index] = buttonDown;
+        digitalWrite(led, HIGH);
+      } else {
+        if (buttonStates[index] == buttonDown) {
+          //Serial.print(index);
+          //Serial.println("pressed");
+          buttonStates[index] = buttonPressed;
+          digitalWrite(led, LOW);
+        }
+      }
+
+  
 }
 
 void checkPressing(int led, unsigned int note, int button) {

         displayWrite("sbagliato");
         state = stateEnd;
       }
                delay(1000);
          noTone(tonePin);
          allLedOff();


    displayWrite("ripeti");
    currentPlayingSeqIndex = 0;
    
  }
  
  if (state == statePlay) {
    
    
    
      
  //    stateRedButton = analogRead(A0);
//      stateRedButton = analogRead(A0);
  //    stateRedButton = analogRead(A0);
    //  stateRedButton = analogRead(A0);
  }
  
//  Serial.println(analogRead(A0));
  /*
  if (pressed(redButton) && (state == statePlay)) {
    checkPressing(redLed, NOTE_C4, redButton); 
  } else if (pressed(greenButton) && (state == statePlay)) {
