Heartbeat Sensor
The KY-039 Heartbeat Sensor Module is designed to detect the heart rate of an individual through a person's fingertip by measuring changes in infrared light. This sensor provides an analog output, which allows you to view the heartbeat signal by placing your finger on the module.
These sensor modules are capable of detecting an individual's heart rate. They do this by emitting infrared (IR) light through an LED on one side of the fingertip and detecting minor changes in the received IR using a phototransistor. The fluctuations in the transmitted IR, caused by the blood being pumped through the finger, are analyzed by a program that runs on the microcontroller. The program filters out electrical noise, reads the data, and provides the heart rate measurement.
int sensorPin = A0; // Arbitrary analog pin to connect sensor output to
int period = 100; // Delay in milliseconds between readings
// Initialization
void setup ()
{
Serial.begin (9600); // the baud rate of the serial data
} //===============================================================
// Main //===============================================================
void loop ()
{
static double oldValue = 0; // used for averaging.
int rawValue = analogRead (sensorPin); // Value read from the analog pin.Will be between 0-1024
Serial.println (rawValue);
delay (period);
}