The Keyes-039 or KY039 Heart rate monitor consists of two things, an Infrared LED, and an Infrared Phototransistor. The IR LED should come on whenever the sensor has power and stay on (because it is infrared, you won't be able to see that it is on, but if you look through your cell phone camera as suggested previously you will). The IR photo transistor causes the voltage to change on a "sensor" wire, and this should be connected to one of the Arduino's analog pins.
Here is a picture of the sensor:
And here is a schematic:
There are 3 pins. The top pin (with the backwards S by it) should go to one of the 6 analog pins of the Arduino (A0 to A5), The middle pin should be plugged into 5 volts, and the bottom pin (with the - next to it) should be plugged into ground.
Once the Arduino is powered the IR LED should come on and stay on (check with a cell phone camera).
Commented code for seeing the values is as follows:
// Pulse Monitor Test Script
int ledPin = 13; // This pin is connected on the Arduino board to an LED, if you want to blink this LED
// to indicate a pulse is being detected, defining it here is a good idea, however
// in the code that follows, this is never done, so this line could be deleted.
int sensorPin = 0; // This is the analog sensor pin the backwards S pin is connected to
// you can use any of the analog pins, but would need to change this to match
double alpha = 0.75; // This code uses a rather cool way of averaging the values, using 75% of the
// average of the previous values and 25% of the current value.
int period = 20; // This is how long the code delays in milliseconds between readings (20 mSec)
double change = 0.0; // My guess is that this was going to be used to detect the peaks, but the
// code never does... you can delete this line as well.
// This code runs on startup, it sets ledPin to output so it can blink the LED that is built into the
// Arduino (but then never does), and sets the serial port up for fast 115,200 baud communication
// of the values (make sure you change your serial monitor to match).
void setup ()
{
pinMode (ledPin, OUTPUT); // not used, can remove
Serial.begin (115200); // the baud rate of the serial data
}
void loop ()
{
static double oldValue = 0; // used for averaging.
static double oldChange = 0; // not currently used
int rawValue = analogRead (sensorPin); // This reads in the value from the analog pin.
// this is a 10 bit number, and will be between 0 and 1023
// If this value doesn't change, you've connected up
// something wrong
double value = alpha * oldValue + (1 - alpha) * rawValue; // Calculate an average using 75% of the
// previous value and 25% of the new
Serial.print (rawValue); // Send out serially the value read in
Serial.print (","); // Send a comma
Serial.println (value); // Send out the average value and a new line
oldValue = value; // Save the average for next iteration
delay (period); // Wait 20 mSec
}