 
 void loop()
 {
-
     if(scanning){
-        scanning = false;
-        //result = scanClaps();
-        result = 700;
+        result = scanClaps();
     }else{
         showResult();
     }

        Serial.println("WIN");
    } else if (result >= THRESHOLD_GOOD){
        wordresult = good;
        Serial.println("GOOD");
    } else {
        wordresult = fail;
        Serial.println("FAIL");

}

int scanClaps(){
    boolean keep = true;
    while(keep){
        sensor = analogRead(SOUND_SENSOR);
        sensor_2 = analogRead(SOUND_SENSOR_2);
        if(min(sensor,sensor_2) > 0){
            sensorValue = max(sensor, sensor_2);
            if(sensorValue > THRESHOLD_FAIL){
                clapMeter = clapMeter + sensorValue;
                goodClap++;
            } else {
                if(badClap<100){
                    badClap++;
                } else {
                    keep = false;
                }
            }

        }
    }

    result = clapMeter/goodClap;
    goodClap = 0;
    badClap = 0;
    scanning = false;

    return result;
}

        /*
        setHistogram(sensorValue);

