SeeeduinoArchで割り込みのテスト

Dependencies:   mbed

Committer:
MrBearing
Date:
Sun Mar 09 02:08:05 2014 +0000
Revision:
0:af7b276e73a7
firstcommit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MrBearing 0:af7b276e73a7 1 #include "mbed.h"
MrBearing 0:af7b276e73a7 2
MrBearing 0:af7b276e73a7 3 InterruptIn button(P0_23);
MrBearing 0:af7b276e73a7 4 DigitalOut led(LED1);
MrBearing 0:af7b276e73a7 5 DigitalOut flash(LED4);
MrBearing 0:af7b276e73a7 6
MrBearing 0:af7b276e73a7 7 void flip() {
MrBearing 0:af7b276e73a7 8 led = !led;
MrBearing 0:af7b276e73a7 9 }
MrBearing 0:af7b276e73a7 10
MrBearing 0:af7b276e73a7 11 int main() {
MrBearing 0:af7b276e73a7 12 button.rise(&flip); // attach the address of the flip function to the rising edge
MrBearing 0:af7b276e73a7 13 while(1) { // wait around, interrupts will interrupt this!
MrBearing 0:af7b276e73a7 14 flash = !flash;
MrBearing 0:af7b276e73a7 15 wait(0.25);
MrBearing 0:af7b276e73a7 16 }
MrBearing 0:af7b276e73a7 17 }