Christian Weiß / Mbed 2 deprecated Timer

Dependencies:   mbed

main.cpp

Committer:
Wizo
Date:
2018-11-15
Revision:
0:65dee900759a

File content as of revision 0:65dee900759a:

#include "mbed.h"
Timer timer1; // define timer object
DigitalOut output1(p5); // digital output
void task1(void); // task function prototype
//*** main code
int main()
{
    timer1.start(); // start timer counting
    while(1) {
        if (timer1.read_ms()>=200) { // read time in ms
            task1(); // call task function
            timer1.reset(); // reset timer
        }
    }
}
void task1(void)  // task function
{
    output1=!output1; // toggle output
}