Vjezba 6.2 (2xledtimer)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Beromunja
Date:
Thu Nov 10 17:43:00 2016 +0000
Commit message:
VT2 Matija_Berecek

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	Thu Nov 10 17:43:00 2016 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+Timer timer1 ; // define timer object
+Timer timer2;
+DigitalOut output1(p5); // digital output
+DigitalOut output2(p6);
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 10 17:43:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file