NuMaker GPIO Interrupt with Debounce Setting

main.cpp

Committer:
ccli8
Date:
2017-09-04
Revision:
8:a479ab0a14ef
Parent:
6:b3369ce1a600
Child:
10:286c71f85d6f

File content as of revision 8:a479ab0a14ef:

// 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);
#endif

void flip() {
    led = !led;
}

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