Tuesday, January 31, 2012

Arduino | Pulse Monitor

Maybe I've gone too far??  This pulse monitor uses an infrared (IR) light to detect the blood going through my finger.




Here is the Arduino code.  Most of it is not mine, it's mostly demo code from the example.  I had to change the alpha value to reduce static.


int ledPin = 12;
int sensorPin = 0;

double alpha = 0.60;
int period = 20;
double change = 0.0;
int goingUpSeries = 0;

void setup()                   
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
}

void loop()                    
{
    static double oldValue = 0;
    static double oldChange = 0;
    int rawValue = analogRead(sensorPin);
    double value = alpha * oldValue + (1 - alpha) * rawValue;
    
    Serial.print(rawValue);
    Serial.print(",");
    Serial.println(value);
    
    change = value - oldValue;    
    digitalWrite(ledPin, isGoingUp(change, oldChange));
    oldValue = value;
    oldChange = change;
    
    delay(period);
}

boolean isGoingUp(double change, double oldChange) {
  return (change < 0.0 && oldChange > 0.0);
}


3 comments:

  1. How did you make your sensor tube for heart monitor?

    ReplyDelete
  2. The sensor tube is made from duct tape. The trick is to keep *all* the light out. It took me several attempts before I got it to work. Take a look at the project in the book "30 Arduino Projects for the Evil Genius" by Simon Monk

    http://amzn.com/B003ZUXQB2

    ReplyDelete
  3. Hi. What resistor values did you use?

    The schematic published in the Evill Genius book is not consistent with the list of components? (The schematic also shows 7V power while the breadboard displays 5V. I am confused as to the discrepancies and wonder how you set up your hardware.

    Thanks in advance.

    G

    ReplyDelete