-
Notifications
You must be signed in to change notification settings - Fork 0
/
PulseSensor_BPM_Serial_Print.ino
52 lines (36 loc) · 1.14 KB
/
PulseSensor_BPM_Serial_Print.ino
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
45
46
47
48
49
50
51
52
/*
Title Comments 1
Title Comment 2
*/
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>
/*
Additional Comment If Required
*/
// Variables
const int PulseSensorPurplePin = 0; // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13; // The on-board Arduion LED
int Threshold = 550; // Determine which Signal to "count as a beat", and which to ingore.
/*
All the PulseSensor Playground functions.
*/
PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground Object called "pulseSensor"
void setup() {
Serial.begin(9600); // For Serial Monitor
// Configure the PulseSensor manager.
pulseSensor.analogInput(PulseSensorPurplePin);
pulseSensor.blinkOnPulse(LED13);
pulseSensor.setThreshold(Threshold);
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !");
}
}
void loop() {
delay(20);
// int myInt = pulseSensor.getBeatsPerMinute
if (pulseSensor.sawStartOfBeat()) {
Serial.println("♥ A HeartBeat Happened ! ");
Serial.print("BPM: ");
Serial.println(pulseSensor.getBeatsPerMinute());
}
}