Advertisement
safwan092

Untitled

Feb 28th, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math
  2. #include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library
  3.  
  4. const int PulseWire = 0; // 'S' Signal pin connected to A0
  5. const int LED13 = 13; // The on-board Arduino LED
  6. int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore
  7.  
  8. PulseSensorPlayground pulseSensor; // Creates an object
  9.  
  10. void setup() {
  11. Serial.begin(9600);
  12.  
  13. // Configure the PulseSensor object, by assigning our variables to it
  14. pulseSensor.analogInput(PulseWire);
  15. pulseSensor.blinkOnPulse(LED13); // Blink on-board LED with heartbeat
  16. pulseSensor.setThreshold(Threshold);
  17.  
  18. // Double-check the "pulseSensor" object was created and began seeing a signal
  19. if (pulseSensor.begin()) {
  20. Serial.println("PulseSensor object created!");
  21. }
  22. }
  23.  
  24. void loop() {
  25. int myBPM = pulseSensor.getBeatsPerMinute(); // Calculates BPM
  26.  
  27. if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if a beat happened
  28. Serial.println("♥ A HeartBeat Happened ! "); // If true, print a message
  29. Serial.print("BPM: ");
  30. Serial.println(myBPM); // Print the BPM value
  31. }
  32.  
  33. delay(20);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement