Skip to content

Instantly share code, notes, and snippets.

@IdrisCytron
Last active September 21, 2020 14:06
Show Gist options
  • Save IdrisCytron/52575a7976b0af770f1b11606c98ae48 to your computer and use it in GitHub Desktop.
Save IdrisCytron/52575a7976b0af770f1b11606c98ae48 to your computer and use it in GitHub Desktop.
Heart Rate Monitor Using Pulse Sensor and Maker Nano
/*
Project: Heart Rate Monitor Using Pulse Sensor and Maker Nano
Board: Arduino Nano (Maker Nano)
Connections:
Nano | I2C LCD Grove
GND - GND
5V - VCC
SDA - SDA
SCL - SCL
Nano | Pulse Sensor
GND - GND
5V - VCC
A0 - SIG
External libraries:
- Grove LCD RGB Backlight by Seeed Studio V1.0.0 (Manager)
- PulseSensor Playground by Joel Murphy, Yury Gitman, Brad Needham V1.5.1 (Manager)
*/
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>
#include <rgb_lcd.h>
const int PulseWire = 0;
int Threshold = 550;
PulseSensorPlayground pulseSensor;
rgb_lcd lcd;
byte led, ledOn;
int pulseAdc;
void setup()
{
for (led = 2; led < 13; led++) {
pinMode(led, OUTPUT);
}
Serial.begin(9600);
lcd.begin(16, 2);
pulseSensor.analogInput(PulseWire);
pulseSensor.setThreshold(Threshold);
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !");
lcd.print("Heartrate (BPM)");
}
}
void loop()
{
pulseAdc = analogRead(PulseWire);
ledOn = map(pulseAdc, 0, 1000, 2, 14);
for (led = 2; led < ledOn; led++) { // Turn on LEDs
digitalWrite(led, HIGH);
}
for (led = ledOn; led < 13; led++) { // Turn off LEDs
digitalWrite(led, LOW);
}
int myBPM = pulseSensor.getBeatsPerMinute();
if (pulseSensor.sawStartOfBeat()) {
Serial.println("♥ A HeartBeat Happened ! ");
Serial.print("BPM: ");
Serial.println(myBPM);
lcd.setCursor(0, 1);
lcd.print(myBPM); lcd.print(" ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment