Mark Schwarzer / Mbed 2 deprecated Schwarzer_A3_2_Tickers

Dependencies:   mbed A3_1_Single_Timer

main.cpp

Committer:
markschwarzer
Date:
2020-10-06
Revision:
3:d90d04dce9f2
Parent:
2:de9d94dc0454

File content as of revision 3:d90d04dce9f2:

#include "mbed.h"
Ticker tickerLED2;  //creat ticker object
Ticker tickerLED3; 
DigitalOut LEDOut2(LED2);
DigitalOut LEDOut3(LED3);

void changeLED2()  //the function that will be called by the ticker object.
{
    LEDOut2 = !LEDOut2;
}
void changeLED3() //function called for other ticker object LED3
{
    LEDOut3 = !LEDOut3;
}

int main()
{
    tickerLED2.attach(&changeLED2,0.2); //the address of the function to call
    //and the interval in seconds between
    //calls to that function
    tickerLED3.attach(&changeLED3,0.8); //changing the interval in seconds for LED3

    while(1) {
        wait(0.1);
        wait(0.1);
        wait(0.1);
        wait(0.1);
        wait(0.1);
        //the main loop is spinning every 500ms, but the LED needs to go faster!
    } //while
}