Devices & Components
Arduino Uno Rev3
Solderless Breadboard Full Size
Alphanumeric LCD, 16 x 2
SparkFun Single Lead Heart Rate Monitor - AD8232
Solderless Breadboard Full Size
Rotary potentiometer (generic)
Jumper wires (generic)
Software & Tools
Fritzing
Arduino IDE
Project description
Code
My own heart rate detecting and displaying device
c_cpp
This a device helpful to measure your heart rate
1#define samp_siz 4 2#define rise_threshold 4 3 4int sensorPin = A0; 5 6#include <LiquidCrystal.h> 7LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 8 9void setup() { 10 Serial.begin(9600); 11 lcd.begin(16, 2); 12 lcd.print("heart rate: "); 13} 14 15void loop(){ 16 float reads[samp_siz], sum; 17 long int now, ptr; 18 float last, reader, start; 19 float first, second, third, before, print_value; 20 bool rising; 21 int rise_count; 22 int n; 23 long int last_beat; 24 25 for (int i = 0; i < samp_siz; i++) 26 reads[i] = 0; 27 sum = 0; 28 ptr = 0; 29 30 while(1) 31 { 32 n = 0; 33 start = millis(); 34 reader = 0.; 35 do 36 { 37 reader += analogRead(sensorPin); 38 n++; 39 now = millis(); 40 } 41 while (now < start + 20); 42 reader /= n; 43 sum -= reads[ptr]; 44 sum += reader; 45 reads[ptr] = reader; 46 last = sum / samp_siz; 47 48 if (last > before) 49 { 50 rise_count++; 51 if (!rising && rise_count > rise_threshold) 52 { 53 54 rising=true; 55 first=millis()-last_beat; 56 last_beat=millis(); 57 print_value=60000/(0.035*first + 0.05*second + 0.1*third); 58 59 delay(1500); 60 Serial.print(print_value/2); 61 Serial.print('\n'); 62 63 lcd.setCursor(0, 1); 64 lcd.print(print_value/ 2); 65 66 third = second; 67 second = first; 68 69 } 70 } 71 else 72 { 73 rising = false; 74 rise_count = 0; 75 } 76 before = last; 77 78 79 ptr++; 80 ptr %= samp_siz; 81 } 82 83} 84
Downloadable files
Heart rate sensing device
Heart rate sensing device

Heart rate sensing device
Heart rate sensing device

Comments
Only logged in users can leave comments