Applied engineering Team / Mbed 2 deprecated VT2_Ivana_Mihalj

Dependencies:   mbed

Revision:
7:c56b212b084e
Parent:
6:ca9ae5ce232d
Child:
8:e81d54d7ced6
--- a/main.cpp	Thu Nov 10 18:00:28 2016 +0000
+++ b/main.cpp	Thu Nov 10 18:02:06 2016 +0000
@@ -1,31 +1,28 @@
 #include "mbed.h"
-Timer timer1; // define timer object
-Timer timer2; // define timer object
-DigitalOut output1(p5); // digital output
-DigitalOut output2(p6); // digital output
-void task1(void); // task function prototype
-void task2(void); // task function prototype
+Ticker flipper1;
+Ticker flipper2;
+DigitalOut led1(p5);
+DigitalOut led2(p6);
+void flip1()   // flip 1 function
+{
+    led1 = !led1;
+}
+void flip2()   // flip 2 function
+{
+    led2 = !led2;
+}
 int main()
 {
-    timer1.start(); // start timer1 counting
-    timer2.start(); // start timer2 counting
+    led1 = 0;
+    led2 = 0;
+    flipper1.attach(&flip1, 0.2); // the address of the
+// function to be attached
+// and the interval (sec)
+    flipper2.attach(&flip2, 1.0);
+// spin in a main loop
+// flipper will interrupt it to call flip
     while(1) {
-        if (timer1.read_ms()>=200) { // read time
-            task1(); // call task1 function
-            timer1.reset(); // reset timer
-        }
-        if (timer2.read_ms()>=1000) { // read time
-            task2(); // call task2 function
-            timer2.reset(); // reset timer
-        }
+        wait(0.2);
     }
 }
-//*** task functions
-void task1(void)
-{
-    output1=!output1; // toggle output1
-}
-void task2(void)
-{
-    output2=!output2; // toggle output2
 }
\ No newline at end of file