![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A
Fork of Timer_HelloWorld by
Revision 2:a8ab43d7fa70, committed 2014-12-04
- Comitter:
- srijani987
- Date:
- Thu Dec 04 00:59:02 2014 +0000
- Parent:
- 1:d76f5570bd21
- Commit message:
- Speaker
Changed in this revision
TextLCD.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Thu Dec 04 00:59:02 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- 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