megan gimple / Mbed 2 deprecated gimple_A3_1_Ticker

Dependencies:   mbed

main.cpp

Committer:
slicht_instructor
Date:
2020-10-04
Revision:
1:76d11e984b8d
Parent:
0:5597320f2dba
Child:
3:f6547e1c1dfc

File content as of revision 1:76d11e984b8d:

//Base code for modification for Assignment 3.2
//Blinks LED2 every 200ms using a single Ticker object.
//Created: S. Licht, 10/04/2020
#include "mbed.h"
Ticker tickerLED2;  //creat ticker object
DigitalOut LEDOut2(LED2);

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

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

    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
}