NuMaker GPIO Interrupt with Debounce Setting

main.cpp

Committer:
cyliang
Date:
2019-10-24
Revision:
17:707b60147ca6
Parent:
15:d825021a7e5b
Child:
18:a53eb3c1d7b7

File content as of revision 17:707b60147ca6:

// GPIO interrupt to set led on/off
#include "mbed.h"

#if defined(TARGET_NUMAKER_PFM_NUC472)
InterruptIn button(SW1);
DigitalOut led(LED1);
#elif defined(TARGET_NUMAKER_PFM_M453)
InterruptIn button(SW2);
DigitalOut led(LED1);
#elif defined(TARGET_NUMAKER_PFM_M487)
InterruptIn button(SW2);
DigitalOut led(LED1);
#elif defined(TARGET_NUMAKER_IOT_M487)
InterruptIn button(SW2);
DigitalOut led(LED1);
#elif defined(TARGET_NUMAKER_PFM_NANO130)
InterruptIn button(SW2);
DigitalOut led(LED1);
#elif defined(TARGET_NUMAKER_PFM_M2351)
InterruptIn button(SW2);
DigitalOut led(LED1);
#elif defined(TARGET_NUMAKER_IOT_M263A)
InterruptIn button(PG_4); // Button1 (SW10)
DigitalOut led(LED1);
#endif

void flip() {
    led = !led;
}

int main() {
    button.rise(&flip);
}