hello everybody,
I am working on a Heart Rate Monitoring project, and need some assistance on it...
I have a code which gives output as "BPM" from a Heart Rate Monitoring Sensor AD8232, I am getting proper output from the code.
with this Heart Rate monitoring device, I also have GPS in my system which consists of delays etc..
i don't want GPS code and Heart rate monitoring code gets conficts.
I want to run this Heart Rate monitoring code on Timer2.
how to do that.?
Code :
int x = 0;
int LastTime = 0;
bool BPMTiming = false;
bool BeatComplete = false;
int BPM = 0;
#define UpperThreshold 518
#define LowerThreshold 495
int LED13 = 44; // The on-board Arduion LED
int Signal; // holds the incoming raw data. Signal value can range from 0-1024
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED13, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(9600);
}
void loop()
{
int value = analogRead(0);
if (value > UpperThreshold)
{
if (BeatComplete)
{
BPM = millis() - LastTime;
BPM = int(60 / (float(BPM) / 1000));
BPMTiming = false;
BeatComplete = false;
}
if (BPMTiming == false)
{
LastTime = millis();
BPMTiming = true;
}
}
if ((value < LowerThreshold) & (BPMTiming))
BeatComplete = true;
x++;
Signal = analogRead(0); // Read the PulseSensor's value.
if (Signal > UpperThreshold) { // If the signal is above "550", then "turn-on" Arduino's on-Board LED.
digitalWrite(LED13, HIGH);
} else {
digitalWrite(LED13, LOW); // Else, the sigal must be below "550", so "turn-off" this LED.
}
Serial.print(BPM);
Serial.print(",");
Serial.println(Signal);
}
Please help
thanks