Nuvoton
/
NuMaker-mbed-GPIO_Interrupt
NuMaker GPIO Interrupt with Debounce Setting
main.cpp@0:29e056412215, 2016-10-14 (annotated)
- Committer:
- rkuo2000
- Date:
- Fri Oct 14 07:59:15 2016 +0000
- Revision:
- 0:29e056412215
- Child:
- 2:15b06747ce59
GPIO interrupt input to flash led1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rkuo2000 | 0:29e056412215 | 1 | // NuMaker-PFM-NUC472 : GPIO interrupt to set led on/off |
rkuo2000 | 0:29e056412215 | 2 | #include "mbed.h" |
rkuo2000 | 0:29e056412215 | 3 | |
rkuo2000 | 0:29e056412215 | 4 | InterruptIn button(PG_1); // D0 |
rkuo2000 | 0:29e056412215 | 5 | DigitalOut led(LED1); // flashing LED1(rgbled1) |
rkuo2000 | 0:29e056412215 | 6 | |
rkuo2000 | 0:29e056412215 | 7 | void flip() { |
rkuo2000 | 0:29e056412215 | 8 | led = !led; |
rkuo2000 | 0:29e056412215 | 9 | } |
rkuo2000 | 0:29e056412215 | 10 | |
rkuo2000 | 0:29e056412215 | 11 | int main() { |
rkuo2000 | 0:29e056412215 | 12 | button.rise(&flip); // if D0 is floating, then rgbled will be flashing |
rkuo2000 | 0:29e056412215 | 13 | } |