ハイパー・マイコン mbedでインターネット 電子工作 1章 リスト1-1 HumanDetection のプログラム

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sunifu
Date:
Wed Jul 09 13:06:03 2014 +0000
Commit message:
????????? mbed???????? ???? ??? 1-1 ( HumanDetection)

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
diff -r 000000000000 -r a5beca894c46 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 09 13:06:03 2014 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+
+#define INIT 7.0
+#define NOISE 3.0
+#define DELAY 10.0
+
+Ticker flipper;
+
+DigitalOut led1(LED1); 
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalIn msensor(p20);
+ 
+void flip() {
+    led1 = !led1;
+}
+
+int main() {
+    led2 = 0;
+    led3 = 0;
+    
+    flipper.attach(&flip, 0.3); 
+    wait( INIT );
+    flipper.detach();
+    led1=0;
+    
+    while(1) {
+        led2 = msensor;
+        if ( led2 == 1 ){
+            wait( NOISE );
+            led2 = msensor;
+
+            while ( led2 == 1 ){        
+                led3 = 1;        
+                wait( DELAY ) ;
+                led2 = msensor;
+            }
+            led3 = 0;
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a5beca894c46 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jul 09 13:06:03 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc
\ No newline at end of file