Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- loicguibert
- Date:
- 2019-02-27
- Revision:
- 0:cbc40e6ff273
- Child:
- 1:4010b3131918
File content as of revision 0:cbc40e6ff273:
#include "mbed.h" #include "rtos.h" #include "Logger.h" #include "BusyWaiter.h" // Set the used LED DigitalOut led1(LED1); // Set the duration between the LED's blinking int wait_time = 1000; // Set the basic waiting mechanism BusyWaiter busy_waiter; // Set the logger handler Logger logger(true); int main () { Logger logger(false); // defining which waiting mechanism we want to use bool deep_sleep_mode = true; logger.log("Entering blinking state.\n"); while (true) { // Blink LED by inversing its state led1 = !led1; if (deep_sleep_mode) { /* As seen on the TP1's doc: * Using the ThisThread::sleep_for() method: this method allows the CPU to * enter deep sleep mode and thus to reduce power consumption between events. */ ThisThread::sleep_for(wait_time); } else { /* As seen on the TP1's doc: Using the BusyWaiter::wait() method - the class is provided to you and * you must include it into your project. */ busy_waiter.wait(wait_time); } if (led1.read() == 0) { logger.log("LED state: 0.\n"); } else { logger.log("LED state: 1.\n"); } } }