Vjezba 6.2 (2xledtimer)

Dependencies:   mbed

Fork of VTMatija_Berecek by Matija Berecek

main.cpp

Committer:
Beromunja
Date:
2016-11-10
Revision:
0:9fce9f0f1011

File content as of revision 0:9fce9f0f1011:

#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
}