Pulse sensor playground

Hi,
The Atmega328pb pulse sensor interrupt isn't functioning. Thus, even if I have USE_ARDUINO_INTERRUPTS set to false, it still returns incorrect values and doesn't update often. Please assist me in resolving this issue.

Always show us a good schematic of your proposed circuit.
Show us good images of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.

2 Likes

#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

const int PulseWire = 5;
const int LED13 = 13;
int Threshold = 550;

PulseSensorPlayground pulseSensor;

void setup()
{

Serial.begin(9600);
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13);
pulseSensor.setThreshold(Threshold);
lcd.begin(16, 2);

if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !");

}
}

void loop() {

if (pulseSensor.sawNewSample()) {
int myBPM = pulseSensor.getBeatsPerMinute();

if (pulseSensor.sawStartOfBeat()) {
Serial.println(":heart: A HeartBeat Happened ! ");
lcd.setCursor(0, 0);
lcd.print(" Heart rate ");
Serial.print("BPM: ");
lcd.setCursor(0, 1);
lcd.print(myBPM, 1);
lcd.print("BPM ");

Serial.println(myBPM);
}
}
delay(20);
}

In glancing through the library, it seems that the pin used here has to be an analog input. You've specified pin 5. Now, had you showed us a schematic, we would have known if you were actually connecting digital pin 5 or to A5 (analog pin 5). But since you haven't shown us a schematic, even though you've been asked nicely to, we can't tell. Nor have you used code tags to enclose your sketch, even though you were also asked to do so.

It would be to your benefit to take the time to read How to get the best out of this forum before continuing.

hrm_sensor

Try setting const int PulseWire to point to the correct pin. A5 and 5 are not the same.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.