CNAP

Heart Beat Sensor Reference

An optical (photoplethysmography-style) pulse sensor that outputs an analog signal proportional to blood flow, used to detect heartbeats.

Pin names

NameDescription
GNDGround
VCCPower (5V)
OUTSignal — analog output, pulses with each heartbeat

Attributes

This component has no configurable attributes.

Usage

Connect VCC to 5V, GND to GND, and OUT to an analog input pin. Detect beats by watching for peaks that cross a threshold above the signal's rolling baseline.

const int PULSE_PIN = A0;
int threshold = 550;
bool beatDetected = false;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int signal = analogRead(PULSE_PIN);

  if (signal > threshold && !beatDetected) {
    beatDetected = true;
    Serial.println("Beat!");
  } else if (signal < threshold) {
    beatDetected = false;
  }

  delay(10);
}

Real-world pulse detection typically needs signal filtering and per-user threshold calibration — this example shows the basic read pattern only.

Examples

DescriptionAttrs
Default pulse sensor{}

See also