-
Notifications
You must be signed in to change notification settings - Fork 0
/
heart_rate.c
44 lines (27 loc) · 894 Bytes
/
heart_rate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//https://github.com/WorldFamousElectronics/PulseSensorPlayground
define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>
// Variables
const int PulseWire = 0;
const int LED13 = 13;
int Threshold = 550;
PulseSensorPlayground pulseSensor;
void setup() {
Serial.begin(9600);
// Configure the PulseSensor object
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13);
pulseSensor.setThreshold(Threshold);
if (pulseSensor.begin()) {
Serial.println("pulseSensor Object created!");
}
}
void loop() {
int myBPM = pulseSensor.getBeatsPerMinute();
if (pulseSensor.sawStartOfBeat()) {
Serial.println("Heart beat");
Serial.print("BPM: ");
Serial.println(myBPM);
}
delay(100);
}