Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:5d80af5c7773
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 29 03:29:19 2015 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" + +//------------------------------------ +// Hyperterminal configuration +// 9600 bauds, 8-bit data, no parity +//------------------------------------ + +Serial pc(SERIAL_TX, SERIAL_RX); + +/*PwmOut mypwm(PWM_OUT); +DigitalOut myled(LED1);*/ +InterruptIn mybutton(USER_BUTTON); + +Timer t; + +int main() { + + int f = 0; + while(1) { + if (mybutton == 0) { + t.start(); + f = 1; + } + else if (f == 1 && mybutton == 1) { + t.stop(); + f = 0; + pc.printf("The time taken was %f seconds", t.read()); + t.reset(); + } + } +} \ No newline at end of file