Christian Weiß / Mbed 2 deprecated Timer

Dependencies:   mbed

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 DigitalOut output1(p5); // digital output
00004 void task1(void); // task function prototype
00005 //*** main code
00006 int main()
00007 {
00008     timer1.start(); // start timer counting
00009     while(1) {
00010         if (timer1.read_ms()>=200) { // read time in ms
00011             task1(); // call task function
00012             timer1.reset(); // reset timer
00013         }
00014     }
00015 }
00016 void task1(void)  // task function
00017 {
00018     output1=!output1; // toggle output
00019 }