Srijani Dutta
/
Timer_HelloWorld1
A
Fork of Timer_HelloWorld by
main.cpp
- Committer:
- srijani987
- Date:
- 2014-12-04
- Revision:
- 2:a8ab43d7fa70
- Parent:
- 0:27e1de20d3cb
File content as of revision 2:a8ab43d7fa70:
#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 timer; DigitalOut led(LED1); int begin, end; int beats=0; int b=0; int hr=0; int samplerate=10; 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); }