割り込み制御

Dependencies:   mbed

Revision:
1:8f5fb022c757
Parent:
0:88cb63e043c1
Child:
2:04dcded3ccae
--- a/main.cpp	Mon Aug 24 07:42:12 2015 +0000
+++ b/main.cpp	Fri Aug 28 17:03:39 2015 +0000
@@ -1,9 +1,18 @@
 #include "mbed.h"
-//Digital port reversal.
-DigitalOut port7(D7);
+
+InterruptIn emergencyBTN(PC_13);//割り込み_青色ボタン
+DigitalOut emergencyLED(PA_8);//外部LED
+DigitalOut statusLED(PA_5);//内部LED
+
+void emergencyLoop(){
+    //割り込みループ処理
+    emergencyLED = !emergencyLED;//外部LEDを反転
+}
+
 int main() {
+    emergencyBTN.fall(&emergencyLoop);//ボタンが押されたら割り込みループへ
     while(1) {
-        port7 = !port7; //D7 port 
-        wait(0.2); // 200 ms
+        statusLED = !statusLED;//内部LEDを反転
+        wait(0.5);
     }
-}
+}
\ No newline at end of file