Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 1:08d5b02b7eb4
- Parent:
- 0:4691e3b49e88
- Child:
- 2:c65e1c89824c
diff -r 4691e3b49e88 -r 08d5b02b7eb4 main.cpp
--- a/main.cpp Sat Feb 25 19:15:55 2017 +0000
+++ b/main.cpp Tue Feb 28 17:09:27 2017 +0000
@@ -1,18 +1,46 @@
#include "mbed.h"
-PwmOut mypwm(PWM_OUT);
-
DigitalOut myled(LED1);
+DigitalIn myPulse(D7);
+Timer timer;
+//void serviceMyPulse(void);
int main() {
-
- mypwm.period_ms(10);
- mypwm.pulsewidth_ms(1);
+ myled=0;
+ float HeartBeat=0.0f;
+ //myPulse.rise(&serviceMyPulse);
+ printf("Heart Beat Monitor!\n\r");
+ timer.start();
+ timer.reset();
+ while(true){
+ while(myPulse==0){wait_ms(50);}
+ while(myPulse==1){wait_ms(50);}
+ HeartBeat=timer.read();
+ //to convert this time we need to perform a BPM=(1/t)*60
+ HeartBeat=(1.0f/HeartBeat)*60.0f;
+ printf("Heart Beat is: %5.1f\n\r",HeartBeat);
+ if (HeartBeat < 50.0f){
+ printf( "Warning, low Heartbeat \n\r");
+ }
+ if (HeartBeat > 90.0f){
+ printf("Warning, high HeartBeart \n\r");
+ }
+
+ if (HeartBeat == NULL){
+ printf("WARNING, Heart Stopped!!!! \n\r");
+ }
+
+ timer.reset();
+ myled=1;
+ wait_ms(100);
+ myled=0;
+ }
- printf("pwm set to %.2f %%\n", mypwm.read() * 100);
-
- while(1) {
- myled = !myled;
- wait(1);
+}
+/*
+void serviceMyPulse(void){
+ myled=1;
+ wait_ms(100);
+ myled=0;
}
-}
+*/
\ No newline at end of file