タイマー割り込み_周期

Dependencies:   mbed

LED1とLED2を別々の周期で点滅

https://mbed.org/users/okini3939/notebook/Ticker_jp/

Files at this revision

API Documentation at this revision

Comitter:
hasimo
Date:
Wed Jul 23 10:41:19 2014 +0000
Commit message:
???????????

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	Wed Jul 23 10:41:19 2014 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+ 
+Ticker flipper;
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+ 
+void flip() {
+    led2 = !led2;
+}
+ 
+int main() {
+    led2 = 1;
+    flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+ 
+    // spin in a main loop. flipper will interrupt it to call flip
+    while(1) {
+        led1 = !led1;
+        wait(0.2);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jul 23 10:41:19 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file