       Serial.print("\t");
     }
     Serial.println("");
-
-  }
-
-  if (diff > 2 * magAvg[0] && phaseNearZero) {
-    digitalWrite(LED_PIN, HIGH);
 
     Serial.print("BPM:\t");
     for (int i = 0; i < endIndex; i++) {

    for (int i = startIndex; i < endIndex; i++) {
        float magnitude = mag[i];
        magAvg[i] = magAvg[i] * 0.99 + magnitude * 0.01;
        if (magAvg[i] > maxMag && i > 1) {
            maxMag = magAvg[i];
            maxIndex = i;
        }

      float newVal = tempBuffer[i];
      lowPass += newVal;
      if (++numInLowPass >= LOW_PASS_SIZE) {
        lowPass /= LOW_PASS_SIZE;
        acc += lowPass * lowPass;
        lowPass = 0;
        numInLowPass = 0;
        numInAcc++;
      }

      if (numInAcc >= ACC_SIZE) {
          addToFFT(acc / 2048);
          acc = 0;
          numInAcc = 0;
      }
