The original code is from WorldFamousElectronics. I've just modified it to work with Teensy v3.2, mainly adding "Timer" to control the interrupts. In theory, this code should work fine with Teensy v3.1/3.0 however I've not tried yet.
Demo video: https://www.youtube.com/watch?v=_h_uFRIzZH4
I'm using this PulseSensor app for reading and calculating the BPM from the USB serial port from teensy board.
This is what the board layout looks like:
- Blinks an LED to User's Live Heartbeat
- Fades an LED to User's Live HeartBeat
- Determines BPM
- Prints All of the Above to Serial
-
Take the PulseSensor_Amped_Arduino-master.zip file, and move it to your Documents/Arduino folder.
-
Unzip PulseSensor_Amped_Arduino-master.zip in your Documents/Arduino folder.
This properly installs your files
-
Or, 0pen project in *Arduino via File > Sketchbook > PulseSensor_Arduino-Master > PulseSensorAmped_Arduino_1dot2.ino
Arduino Pin | Pulse Sensor Cable Color |
---|---|
RED | 5V or 3V |
BLACK | GND (GROUND) |
PURPLE | ANALOG 0 (Zero) |
##Variables to Note
Variable Name | What it does |
---|---|
Signal | Int that holds **raw Analog Input data on Pin 0, the Pulse Sensor's Purple Cable. It's updated every 2mS. |
BPM | Int that holds the heart-rate value, derived every beat, from averaging previous 10 IBI values. |
IBI | Int that holds the time interval between beats! Must be seeded! |
Pulse | Boolean that is true when a heartbeat is sensed. It's false other times. It controls LED Pin 13. |
QS | Boolean that is true whenever Pulse is found and BPM is updated. User must reset. |
This Arduion App works with:
- Works with our Processing App "Processing Visualizer"
- Works with our Pulse Sensor Mac App "Pulse Sensor Mac App"
- Works with any third-party serial reader.
See the User's Pulse & BPM without leaving Arduino. Open the serial monitor for this ASCII visualization.
To Turn On ASCII Visualizer:
// Regards Serial OutPut -- Set This Up to your needs
static boolean serialVisual = false; // Set to 'false' by Default.
too:
// Regards Serial OutPut -- Set This Up to your needs
static boolean serialVisual = true; // Re-set to 'true' to do ASCII Visual Pulse : )
That's it's! Upload and open your Arduino Serial Monitor.
There is a tab in the Arduino code called Timer_Interrupt_Notes. This page describes how to set up the Timer interrupt depending on which version of Arduino you are using, and what other things you may want to do with your sketch. Please read it carefully!
PWM on pins 3 and 11 will not work when using this code, because we are using Timer 2!