![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Timeout Örneği
Dependencies: mbed
Fork of Timer_HelloWorld by
Diff: main.cpp
- Revision:
- 1:640a6cabee81
- Parent:
- 0:27e1de20d3cb
diff -r 27e1de20d3cb -r 640a6cabee81 main.cpp --- a/main.cpp Wed Feb 13 17:28:57 2013 +0000 +++ b/main.cpp Fri May 11 05:14:35 2018 +0000 @@ -1,10 +1,27 @@ #include "mbed.h" - -Timer t; - + +Timeout response; +DigitalIn button (USER_BUTTON); +DigitalOut led1(LED1); + +void led_set(void); +void led_clear(void); + int main() { - t.start(); - printf("Hello World!\n"); - t.stop(); - printf("The time taken was %f seconds\n", t.read()); + while(true) { + if(button == 0){ // Butona basıldı ise + response.attach(&led_set, 3.0); + } + printf("buton girisi bekleniyor!\n"); + wait(0.2); + } } + +void led_set(void) { + led1 = 1; + response.attach(&led_clear, 2.0); +} + +void led_clear(void) { + led1 = 0; +}