Mark Schwarzer / Mbed 2 deprecated Schwarzer_A3_1_Timers

Dependencies:   mbed

main.cpp

Committer:
markschwarzer
Date:
2020-10-06
Revision:
1:60db0821e5bc
Parent:
0:5597320f2dba
Child:
2:1692cf4dda7f

File content as of revision 1:60db0821e5bc:


//Blinks LED2 every 200ms using a single Timer object.


#include "mbed.h"

Timer timerLED2;  //creat timer object
DigitalOut LEDOut2(LED2);

int main()
{
    timerLED2.start(); //start timer counting

    while(1) {
        if (timerLED2.read_ms()>=200) { //check to see if time has been exceeded
            LEDOut2 = !LEDOut2;
            timerLED2.reset();  //reset the timer back to zero
        }  //if timer

        //if you had other code that you wanted to execute faster,
        //you could put it here!
        
    } //while
}