Arduino

XD-58C 펄스심박센서 BPM/IBI/SIG 확인 LED 깜박이기

작성자 임베디드코리아 작성일26-06-21 00:12 조회21회 댓글0건
◆ BPM (Beats Per Minute): 1분 동안 심장이 뛰는 횟수 (예: 60~100 bpm이 정상 성인 기준).
◆ IBI (Inter Beat Interval): 심장 박동과 박동 사이의 시간 간격(밀리초, ms 단위)으로, 심박 변이도(HRV) 분석에 사용됨.
◆ SIG (Signal): 심박 센서(Pulse Sensor 등)에서 측정되는 아날로그/디지털 형태의 실시간 파형 신호.

---<  XD-58C_Pulse-Sensor_BCM-IBI-SIG.ino  >---------------------------------------------
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>

const int OUTPUT_TYPE = SERIAL_PLOTTER;

const int PIN_INPUT = A0;
const int PIN_BLINK = 13;    // Pin 13 is the on-board LED
const int PIN_FADE = 5;
const int THRESHOLD = 550;  // Adjust this number to avoid noise when idle

PulseSensorPlayground pulseSensor;

void setup() {

  Serial.begin(115200);

  // Configure the PulseSensor manager.
  pulseSensor.analogInput(PIN_INPUT);
  pulseSensor.blinkOnPulse(PIN_BLINK);
  pulseSensor.fadeOnPulse(PIN_FADE);

  pulseSensor.setSerial(Serial);
  pulseSensor.setOutputType(OUTPUT_TYPE);
  pulseSensor.setThreshold(THRESHOLD);

  // Now that everything is ready, start reading the PulseSensor signal.
  if (!pulseSensor.begin()) {

    for(;;) {
      // Flash the led to show things didn't work.
      digitalWrite(PIN_BLINK, LOW);
      delay(50);
      digitalWrite(PIN_BLINK, HIGH);
      delay(50);
    }
  }
}

void loop() {

  delay(20);

  // write the latest sample to Serial.
  pulseSensor.outputSample();

  if (pulseSensor.sawStartOfBeat()) {
  pulseSensor.outputBeat();
  }
}
----------------------------------------------------------------------------------------------------------