タイマー割込みのサンプルプログラム

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
GGU
Date:
Mon Jul 29 04:45:54 2019 +0000
Commit message:
test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jul 29 04:45:54 2019 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+
+//Ticker flipper;
+DigitalOut led1(A0);
+DigitalOut led2(LED1);
+
+/*void flip(){
+    led2=!led2;
+    flipper.attach(&flip,2.0);
+}
+
+int main(){
+    led2 = 1;
+    flipper.attach(&flip,2.0);
+    while(1){
+        led1 = !led1;
+        wait(0.2);
+    }
+}*/
+
+
+Ticker flipper;
+
+void flip(){
+    led2=!led2; //LED is OFF
+    flipper.attach(&flip,2.0);
+}
+
+int main(){
+    led2 = 1;   //LED2 is ON
+    flipper.attach(&flip,2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+    while(1){
+        led1 = !led1;   //LED1は0.2sずつ点滅
+        wait(0.2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jul 29 04:45:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file