Timer multipli

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
MDevolution
Date:
Mon Oct 31 10:35:24 2016 +0000
Commit message:
Esercitazione5_4

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 31 10:35:24 2016 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+Timer timer_fast; // define Timer with name "timer_fast"
+Timer timer_slow; // define Timer with name "timer_slow"
+DigitalOut out1(D7);
+DigitalOut out2(D8);
+
+void task_fast(void); //function prototypes
+void task_slow(void);
+
+int main() {
+    timer_fast.start(); //start the Timers 
+    timer_slow.start();
+    
+    while(1){
+        if(timer_fast.read_ms()>1){
+            task_fast();
+            timer_fast.reset();   
+        }
+        if(timer_slow.read_ms()>10){
+            task_slow();
+            timer_slow.reset(); 
+        }
+    }
+}
+
+void task_fast(void){
+    out1=!out1;    
+}
+
+void task_slow(void){
+    out2=!out2;    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 31 10:35:24 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0
\ No newline at end of file