A

Dependencies:   TextLCD mbed

Fork of Timer_HelloWorld by mbed official

Revision:
2:a8ab43d7fa70
Parent:
0:27e1de20d3cb
--- a/main.cpp	Sat Sep 20 23:00:21 2014 +0000
+++ b/main.cpp	Thu Dec 04 00:59:02 2014 +0000
@@ -1,10 +1,49 @@
-#include "mbed.h"
+ #include "mbed.h"
+ #include "LPC17xx.h"
+#include "TextLCD.h"
+ TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2);
+Serial pc (USBTX, USBRX);
+PwmOut speaker(p21);
  
-Timer t;
+ Timer timer;
+ DigitalOut led(LED1);
+ int begin, end;
+ int beats=0;
+ int b=0;
+ int hr=0;
+ int samplerate=10;
  
-int main() {
-    t.start();
-    printf("Hello World!\n");
-    t.stop();
-    printf("The time taken was %f seconds\n", t.read());
-}
+ int main() {
+     timer.start();
+     
+     while (1){
+         b=timer.read();
+     
+     hr = (b * 60)/samplerate;
+     lcd.locate(0,1);
+        lcd.printf("Beats %d" ,b);
+     if (hr<100) 
+     {
+         
+         lcd.locate(0,0);
+        lcd.printf("heart fine "); 
+        }
+        
+     if (hr>=100)
+     {
+         lcd.cls(); 
+         //lcd.locate(0,0);
+        //lcd.printf("Alarm %d", hr);
+        speaker.period(1.0/500.0); // 500hz period
+        speaker =0.5;
+        timer.reset();
+     }    
+         speaker=0.0; // turn off audio
+
+     }
+     
+     //begin = timer.read_us();
+     led = !led;
+     //end = timer.read_us();
+     //printf("Toggle the led takes %d us", end - begin);
+ }
\ No newline at end of file