Heart Beat elapsed time

Hi! :slight_smile: anyone here knows how to get the elapsed time of every heart beat?
Sorry, but i am just new in doing this.. Thank you, hope someone will help me. :slight_smile: God Bless!

Can you measure the heat beat already?

to time it you need to use the millis() function and store its value in a variable e.g. lastHB

unsigned long lastHeartBeat = 0;

....

void loop()
{
  if (heartBeat())
  {
    unsigned long now = millis();
    unsigned long duration = now - lastHeartBeat;
    lastHeartBeat = now;
    Serial.println(duration);
   
    .....

}

Sounds to though Rob, that the OP wants to measure the length of the beat itself, not the time between them.

JimboZA:
Sounds to though Rob, that the OP wants to measure the length of the beat itself, not the time between them.

Then timing the analogReads() above a threshold could do the trick?

while (analogRead(A0) < THRESHOLD); // wait for beat
start = micros();

while (analogRead(A0) >= THRESHOLD); // wait for beat
stop = micros();

duration = stop - start;

Ohh, sorry sir Rob and sir Jimboza for sending this question as PM, i'm just new here and just exploring this arduino forum so i didn't notice.sorry again. now i know what to do next time :slight_smile:

anyway, yes sir Rob, i can already get the heartbeat, the time i want to get is the time between heartbeats. Thank you for answering :slight_smile: I will apply and study your codes you've given :slight_smile:

thank you! :slight_smile: God Bless.

Please post your final solution as reference for the future

I didn't get a PM though.... are PMs working does anyone know?

Ah so you were right first time there, Rob.

As a matter of interest Connie, what are you using to pick up the beat, and are you picking up only the beat or going for an ECG?

JimboZA:
As a matter of interest Connie, what are you using to pick up the beat, and are you picking up only the beat or going for an ECG?

hi :slight_smile: sorry for the late reply.. are you asking about the sensor? anyway, i'm using a gizduino (clone of arduino) and a heart rate kit (sensor)..

Only the beat but if possible, we'll do the ECG..