トランジスタ技術2015年6月号mbedラジコン・カーp179 リスト2 障害物検知器のmbedメイン・プログラム

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
YoshihitoShimada
Date:
Mon Jun 01 02:46:57 2015 +0000
Commit message:
sonar test program

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 Jun 01 02:46:57 2015 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+
+PwmOut S40kHz(P0_21);
+
+AnalogIn Ain(P0_13);
+
+DigitalOut StopSignal(P0_20);
+
+int main() {
+
+    float threshold=0.2;
+
+    S40kHz.period_us(25);          // 40kHz
+    S40kHz.pulsewidth_us(12.5);
+
+    while (1) {
+        if(Ain > threshold) {
+            StopSignal=0;         // Red LED ON
+        } else {
+            StopSignal=1;         // Red LED OFF
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 01 02:46:57 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file