Annexe 1 Xd58c Arduino

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 2

ANNEXE 1: XD-58C ARDUINO

1. #include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.


2.
3. // Variables
4. const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
5. const int LED = LED_BUILTIN; // The on-board Arduino LED, close to PIN 13.
6. int Threshold = 550; // Determine which Signal to "count as a beat" and
which to ignore.
7. // Use the "Gettting Started Project" to fine-tune Threshold Value
default setting. beyond
8. // Otherwise leave the default "550" value.
9.
10. PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground
object called "pulseSensor"
11.
12.
13. void setup() {
14.
15. Serial.begin(115200); // For Serial
Monitor 16.
17. // Configure the PulseSensor object, by
assigning our variables to it.
18. pulseSensor.analogInput(PulseWire);
19. pulseSensor.blinkOnPulse(LED); //
auto-magically blink Arduino's LED with
heartbeat.
20.pulseSensor.setThreshold(Threshold);
21.
22. // Double-check the "pulseSensor"
object was created and "began"
seeing a signal.
26. }
23. if (pulseSensor.begin()) {
27.
24. Serial.println("We created a pulseSensor Object !"); //This prints one time at
28.
Arduino power-up, or on Arduino reset.
29.
25. }
30. void loop() {
31.
32.
33.
34. if // Constantly test to see if "a beat happened".
(pulseSensor.sa
35. int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object
wStartOfBeat())
that returns BPM as an "int".
{
36. // "myBPM" hold this BPM value now.

37. Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a
38. heartbeat
happened".
Serial.print("BPM: "); // Print phrase "BPM: "
39. Serial.println(myBPM); // Print the value inside of myBPM.
40. }
41.
42. delay(20); // considered best practice in a simple sketch.
43.
44. }
45.

You might also like