Applied engineering Team / Mbed 2 deprecated VT2matija_berecek

Dependencies:   mbed

Fork of VTMatija_Berecek by Matija Berecek

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 Timer timer1 ; // define timer object
00003 Timer timer2;
00004 DigitalOut output1(p5); // digital output
00005 DigitalOut output2(p6);
00006 void task1(void); // task function prototype
00007 void task2(void);
00008 //*** main code
00009 int main() {
00010 timer1.start(); // start timer1 counting
00011 timer2.start(); // start timer2 counting
00012 while(1) {
00013 if (timer1.read_ms()>=200) // read time
00014 {
00015 task1(); // call task1 function
00016 timer1.reset(); // reset timer
00017 }
00018 if (timer2.read_ms()>=1000) // read time
00019 {
00020 task2(); // call task2 function
00021 timer2.reset(); // reset timer
00022 }
00023 }
00024 }
00025 //*** task functions
00026 void task1(void){
00027 output1=!output1; // toggle output1
00028 }
00029 void task2(void){
00030 output2=!output2; // toggle output2
00031 }