NuMaker GPIO Interrupt with Debounce Setting

main.cpp

Committer:
shliu1
Date:
2016-12-22
Revision:
5:b9b7cd06aaf0
Parent:
2:15b06747ce59
Child:
6:b3369ce1a600

File content as of revision 5:b9b7cd06aaf0:

// NuMaker-PFM-NUC472 : GPIO interrupt to set led on/off
#include "mbed.h"
#if defined(TARGET_NUMAKER_PFM_NUC472)
InterruptIn button(SW1);    // Button SW1
DigitalOut led(LED1);       // flashing LED1(rgbled1)
#elif defined(TARGET_NUMAKER_PFM_M453)
InterruptIn button(SW1);    // Button SW1
DigitalOut led(LED1);       // flashing LED1(rgbled1)
#endif

void flip() {
    led = !led;
}

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