 }
 
 int scanClaps(){
-    sensor = analogRead(SOUND_SENSOR);
-    sensor_2 = analogRead(SOUND_SENSOR_2);
-
-    if(min(sensor,sensor_2) > 0)
-    {
-        sensorValue = max(sensor, sensor_2);
+    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);
 

        }
        */

        if(sensorValue > THRESHOLD_FAIL)
        {
            clapMeterOn = true;
            clapMeter = clapMeter + sensorValue;
            counter++;
        }
   }
   if (clapMeterOn == true && sensorValue < 50)
   {
        average = clapMeter/counter;
        Serial.println("FIN DEL CONTEO");
        Serial.println(average);
        clapMeterOn = false;
        //show_results

        counter = 0;
        clapMeter = 0;
    }

    scanning = false;

}

void lcd_init()
{

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