예제2) 인터럽트

Dependencies:   mbed

Fork of ex1_mbed_first by 안양어벤저스

Files at this revision

API Documentation at this revision

Comitter:
robertchoi
Date:
Fri Oct 13 02:44:54 2017 +0000
Parent:
1:edee77006ef2
Commit message:
??2 ????

Changed in this revision

int.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
diff -r edee77006ef2 -r 6f28c6a05b96 int.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/int.cpp	Fri Oct 13 02:44:54 2017 +0000
@@ -0,0 +1,16 @@
+#include "mbed.h"
+
+InterruptIn event(D5);
+DigitalOut led(LED1);
+
+void trigger() {
+    printf("triggered!\n");
+}
+
+int main() {
+    event.rise(&trigger);
+    while(1) {
+        led = !led;
+        wait(0.25);
+    }
+}
diff -r edee77006ef2 -r 6f28c6a05b96 main.cpp
--- a/main.cpp	Fri Oct 13 01:43:34 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-// Toggle a LED
-#include "mbed.h"
-
-DigitalOut led(LED2);
-
-int main() {
-    while(1) {
-        led = !led;
-        wait(0.2);
-    }
-}