NUCLEO-F042K6 Simple demo blinking LED using ticker

Dependencies:   mbed

main.cpp

Committer:
vodsejak
Date:
2018-02-10
Revision:
1:6428af2e51f5
Parent:
0:8eb6644d6308

File content as of revision 1:6428af2e51f5:

#include "mbed.h"

/*******************************************************************************

  EXAMPLE DESCRIPTION
  
  Initialize ticker that periodically (100 ms) calls function that toggles 
  onboard LED.
  
*******************************************************************************/

Ticker tick; // Ticker definition

DigitalOut LED(LED1);  // definition of digital out pin

// Toggles LED
void toggleLED() {
    LED = !LED;
}

int main() {
    tick.attach(&toggleLED, 0.1); // Init the ticker with the address of the 
                                   // function (toggle_led) to be attached and 
                                   // the interval (100 ms)
    while (true) {
        // main programm loop - can do other things
    }
}