Dependencies:   mbed

main.cpp

Committer:
VigneshRSR
Date:
2015-05-29
Revision:
0:5d80af5c7773

File content as of revision 0:5d80af5c7773:

#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();
        }
    }
}