カッコーの音が鳴る歩行者用信号のプログラムです 改変等自由にご利用ください

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kohacraft
Date:
Sat Jul 16 05:55:10 2016 +0000
Commit message:
ver1.0

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 bbb21e7748f7 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jul 16 05:55:10 2016 +0000
@@ -0,0 +1,58 @@
+/* カッコーが鳴る歩行者用信号のプログラムです */
+#include "mbed.h"
+
+DigitalOut sp(dp1); //スピーカーのピンを設定します
+DigitalOut blue(dp13);//1つ目のLEDのピンを設定します
+DigitalOut red(dp14);//2つ目のLEDのピンを設定します
+
+int main() {
+    
+
+    while(1) {
+        blue = 1;   //青を光らせる
+        red = 0;    //赤を消す
+                
+        //カッコーを5回鳴らす
+        for( int i=0 ; i<5 ; i++ )
+        {   
+            //ミの音を鳴らす
+            for( int i=0 ; i<300 ; i++ )
+            {
+                sp = 1;   //スピーカーをON OFF させて音を作る
+                wait(1.0/880.00/4); //1オクターブ上のミ 880*2Hz
+                sp = 0;
+                wait(1.0/880.00/4);
+            
+            }
+            wait(0.2);
+            
+            //ドの音を鳴らす
+            for( int i=0 ; i<700 ; i++ )
+            {
+            
+                sp = 1;
+                wait(1.0/698.45/4); //1オクターブ上のド 698.45*2Hz
+                sp = 0;
+                wait(1.0/698.45/4);
+            
+            }
+            wait(0.8);
+        }
+        
+        //青を点滅させる
+        for( int i=0 ; i<5 ; i++ )
+        {
+            blue = 0;
+            wait(0.25);
+            blue = 1;
+            wait(0.25);
+        }
+        
+        //赤にする
+        blue = 0;   //青を消す
+        red = 1;    //赤を光らせる
+        wait(5);
+    }
+}
+
+
diff -r 000000000000 -r bbb21e7748f7 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jul 16 05:55:10 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file