vjezba 6.2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lgotic
Date:
Thu Nov 10 18:40:48 2016 +0000
Commit message:
vjezba6.2

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
diff -r 000000000000 -r 9e5138f1e4c1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 10 18:40:48 2016 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+Timer timer1; // define timer object
+Timer timer2; // define timer object
+DigitalOut output1(p21); // digital output
+DigitalOut output2(p22); // digital output
+void task1(void); // task function prototype
+
+void task2(void);
+//*** main code
+int main()
+{
+    timer1.start(); // start timer1 counting
+    timer2.start(); // start timer2 counting
+    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
+        }
+    }
+}
+//*** task functions
+void task1(void)
+{
+    output1=!output1; // toggle output1
+}
+void task2(void)
+{
+    output2=!output2; // toggle output2
+}
\ No newline at end of file
diff -r 000000000000 -r 9e5138f1e4c1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 10 18:40:48 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file