Arduino

손가락 펄스 심박 센서 모듈 LED KY-039d

작성자 임베디드코리아 작성일26-06-20 12:32 조회20회 댓글0건
■ PPG (Photoplethysmography)
    ▶ 펄스 센서는 PPG란 방식을 사용한다.
    ▶ PPG(photoplethysmography)란, 광용적 맥파 측정법 또는 광 혈류 측정이라 부는 기술이다..

---<  Finger_Pulse-Sensor_LED.ino  >-----------------------------------
#define PULSE_SENSOR_PIN A0
#define LED_PIN 9

int sensorValue = 0;
int minValue = 885; // LED 밝기가 0이 되는 기준값
int maxValue = 900; // LED 밝기가 255가 되는 기준값

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  // 맥박 센서 값 읽기
  sensorValue = analogRead(PULSE_SENSOR_PIN);
  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);

  // 센서 값에 따라 LED 밝기 변경
  if (sensorValue >= minValue && sensorValue <= maxValue) {
    int ledBrightness = map(sensorValue, minValue, maxValue, 0, 255);
    analogWrite(LED_PIN, ledBrightness);
  } else {
    analogWrite(LED_PIN, 0); // 범위 밖일 때 LED 끄기
  }
  delay(10); // 딜레이를 통해 신호 안정화
}
---------------------------------------------------------------------------------------------------------