Arduino_Pulse sensor
Thu Jan 19 2023 00:42:32 GMT+0000 (Coordinated Universal Time)
Saved by @yc_lan
#define USE_ARDUINO_INTERRUPTS true #include <PulseSensorPlayground.h> const int OUTPUT_TYPE = SERIAL_PLOTTER; const int PULSE_SENSOR_COUNT = 3; const int PIN_INPUT0 = A0; const int PIN_INPUT1 = A1; const int PIN_INPUT2 = A2; int Photoresistor0 = 0; int Photoresistor1 = 0; //const int Photoresistor2 = A5; PulseSensorPlayground pulseSensor(PULSE_SENSOR_COUNT); void setup() { Serial.begin(9600); pulseSensor.analogInput(PIN_INPUT0,0); pulseSensor.analogInput(PIN_INPUT1,1); pulseSensor.analogInput(PIN_INPUT2,2); if (pulseSensor.begin()) { Serial.println("pulseSensorOn"); } } void loop() { //sensor1 int Photoresistor0 = analogRead(A3); // Serial.print("L0,"); // Serial.println(Photoresistor0); if (Photoresistor0<30){ pulseSensor.outputBeat(0); int BPM0 = pulseSensor.getBeatsPerMinute(0); // if (40<BPM0 && BPM0<150){ Serial.print("p0,"); Serial.println(BPM0); // }else{ // Serial.print("p0,"); // Serial.println("0"); // } } else{Serial.print("p0,"); Serial.println("0"); } //sensor2 int Photoresistor1 = analogRead(A4); // Serial.print("L1,"); // Serial.println(Photoresistor1); if (Photoresistor1<30){ pulseSensor.outputBeat(1); int BPM1 = pulseSensor.getBeatsPerMinute(1); // if (40<BPM1&&BPM1<150){ // Serial.print("p1,"); Serial.println(BPM1); // }else{ // Serial.print("p1,"); // Serial.println("0"); // } } else{Serial.print("p1,"); Serial.println("0"); } //sensor3 int Photoresistor2 = analogRead(A5); // Serial.print("L2,"); // Serial.println(Photoresistor2); if (Photoresistor2<30){ pulseSensor.outputBeat(2); int BPM2 = pulseSensor.getBeatsPerMinute(2); // if (40<BPM2 && BPM2<150){ Serial.print("p2,"); Serial.println(BPM2); // }else{ // Serial.print("p2,"); // Serial.println("0"); ; // } } else{Serial.print("p2,"); Serial.println("0"); } delay(700); }
Comments