Timer Örneği-3

Dependencies:   mbed

Fork of Timer_HelloWorld by mbed official

Revision:
1:f2a85aac8280
Parent:
0:27e1de20d3cb
diff -r 27e1de20d3cb -r f2a85aac8280 main.cpp
--- a/main.cpp	Wed Feb 13 17:28:57 2013 +0000
+++ b/main.cpp	Fri May 11 05:14:11 2018 +0000
@@ -1,10 +1,34 @@
 #include "mbed.h"
+
+Timer timer_1;
+Timer timer_2;
+
+DigitalOut led(LED1);
+
  
-Timer t;
+void task_1(void);
+void task_2(void);
  
 int main() {
-    t.start();
-    printf("Hello World!\n");
-    t.stop();
-    printf("The time taken was %f seconds\n", t.read());
+  timer_1.start();
+  timer_2.start(); 
+  while(true){
+    if (timer_1.read() > 0.1) {
+      task_1();
+      timer_1.reset();
+    }
+    if (timer_2.read() > 1) {
+      task_2();
+      timer_2.reset();
+    }
+  }
 }
+ 
+void task_1(void) {
+  led = !led;
+}
+void task_2(void) {
+  static int sayac = 0;  
+  printf("Sayac:%d \n",sayac);
+  sayac++;
+}
\ No newline at end of file