KNTL

Dependencies:   mbed

main.cpp

Committer:
hisyamfs
Date:
2019-05-01
Revision:
0:7850f26e290c

File content as of revision 0:7850f26e290c:

#include "mbed.h"
 
InterruptIn line(PA_0);
Timer timer;
volatile float dur = 0.0f;
int printed = 0;

void start() {
    timer.reset();
    timer.start();
}

void end() {
    timer.stop();
    dur = timer.read();   
}

int main() {
    line.fall(&start);
    line.rise(&end);
    while (1) {
        if (!printed) {
            printf("%.2f\n", dur);
            printed = 1;
        }
        else {
            printed = 0;
        }
    } 
}