   // KickFFT<int32_t>::fft(fs, 0, 4, FFT_SIZE, fftBuffer, mag, startIndex, endIndex);
   fft_phase(FS, 0, F2, FFT_SIZE, fftBuffer, mag, phase, startIndex, endIndex);
   bool phaseNearZero = updatePhase(mag, phase, startIndex, endIndex);
-  if (diff > 0 && phaseNearZero) {
-
-  // Serial.print("BPM:\t");
-  // for (int i = 0; i < endIndex; i++) {
-  //   float hz = FS * phaseRateAverage[i] / 2 / PI;
-  //   float bpm = hz * 60;
-  //   Serial.print(bpm);
-  //   Serial.print("\t");
-  // }
-  // Serial.println("");
-
-  // Serial.print("Phase:\t");
-  // for (int i = 0; i < endIndex; i++) {
-  //   float phase = phaseAvg[i];
-  //   Serial.print(phase);
-  //   Serial.print("\t");
-  // }
-  // Serial.println("");
-
-  Serial.print("Magnitude:\t");
-  for (int i = 0; i < endIndex; i++) {
-    float mag = magAvg[i];
-    Serial.print(mag);
-    Serial.print("\t");
-  }
-  Serial.println("");
-
-  }
+  if (diff > 0 && !phaseNearZero) {
+    digitalWrite(LED_PIN, LOW);
+
+    Serial.print("Phase:\t");
+    for (int i = 0; i < endIndex; i++) {
+      float phase = phaseAvg[i];
+      Serial.print(phase);
+      Serial.print("\t");
+    }
+    Serial.println("");
+
+  } else if (diff > 0 && phaseNearZero) {
+    digitalWrite(LED_PIN, HIGH);
+
+    Serial.print("BPM:\t");
+    for (int i = 0; i < endIndex; i++) {
+      float hz = FS * phaseRateAverage[i] / 2 / PI;
+      float bpm = hz * 60;
+      Serial.print(bpm);
+      Serial.print("\t");
+    }
+    Serial.println("");
+
+    Serial.print("Magnitude:\t");
+    for (int i = 0; i < endIndex; i++) {
+      float mag = magAvg[i];
+      Serial.print(mag);
+      Serial.print("\t");
+    }
+    Serial.println("");
+
+  } else {
+    digitalWrite(LED_PIN, LOW);
+  }
+
 
   // float hz = FS * phaseRateAverage / 2 / PI;
   // Serial.print("endIndex: "); Serial.println(endIndex);

        }
        float magnitude = mag[i];
        magAvg[i] = magAvg[i] * 0.99 + magnitude * 0.01;
        if (magnitude > maxMag) {
            maxMag = magnitude;
            maxIndex = i;
        }


}

float prevPhase[END_INDEX];
uint16_t winningIndex = 0;
float phaseAvg[END_INDEX];
float phaseRateAverage[END_INDEX];
float magAvg[END_INDEX];
