Matthaeus Vorraber
/
app-InterruptIn-Ticker-Timeout
TimerLed
main.cpp
- Committer:
- fpucher
- Date:
- 2019-12-09
- Revision:
- 0:28ab61836d38
- Child:
- 1:4f4f8acfae13
File content as of revision 0:28ab61836d38:
#include "mbed.h" #define BUTTON1 p14 // push joystick pin //#define BUTTON1 A1 // NUCLEO Taster A1 DigitalOut led1(LED1); DigitalOut led2(LED2); // NUCLEO D2 DigitalOut led3(LED3); // NUCLEO D3 Ticker t1; Timeout t2; InterruptIn btn(BUTTON1); void blink_led1() { printf("Ticker fired\n"); led1 = !led1; } void toggle_led2() { printf("BUTTON1 fall invoked\n"); led2 = !led2; } void turn_led3_on() { printf("Timeout fired\n"); led3 = 1; } int main() { printf("Hello world!\n"); printf("LED1 will blink every second, LED3 will toggle after 2.5 seconds, LED2 can be toggled through BUTTON1.\n"); printf("-----------------------------------\n\n"); t1.attach(callback(&blink_led1), 1.0f); t2.attach(callback(&turn_led3_on), 2.5f); btn.fall(callback(&toggle_led2)); while(1) {} // wait_ms(osWaitForever); }