예제3) 타이머
Dependencies: mbed
Fork of ex3_mbed_timer by
Diff: timer.cpp
- Revision:
- 3:02736805f392
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/timer.cpp Fri Oct 13 03:25:03 2017 +0000 @@ -0,0 +1,47 @@ +// Blink until timeout. + +#include "mbed.h" + +Timeout timeout; +DigitalOut led(LED1); + +int secFlag = 1; +int secTic = 0; + +void attimeout() { + secFlag = 1; +} + +int main() { + while(1) { + + if(secFlag) // 1sec + { + secFlag = 0; + timeout.attach(&attimeout, 1); + + secTic++; + + + } + + + if(secTic == 1) + { + led = 0; + wait(0.5); + led = 1; + wait(0.5); + } + + if(secTic == 10) + { + led = 0; + wait(0.5); + led = 1; + wait(0.5); + } + + + } +}