Low-powered blinky example

Dependencies:   mbed

Blinks an LED using a low-power ticker.

Uses the asynchronous APIs and improved sleep API.

main.cpp

Committer:
stevew817
Date:
2016-09-12
Revision:
4:0bf3fe309b3e
Parent:
3:c950338a014e

File content as of revision 4:0bf3fe309b3e:

#include "mbed.h"
 
DigitalOut myled(LED1);
LowPowerTicker toggleTicker;

/**
* This is a callback! Do not call frequency-dependent operations here.
*
* For a more thorough explanation, go here: 
* https://developer.mbed.org/teams/SiliconLabs/wiki/Using-the-improved-mbed-sleep-API#mixing-sleep-with-synchronous-code
**/
void ledToggler(void) {
    myled = !myled;
}
 
int main() {
    toggleTicker.attach(&ledToggler, 0.2f);
    while(1) {
        sleep();
    }
}