スピーカーで音を鳴らす

Dependencies:   mbed

Revision:
0:f5bba12ef049
Child:
1:42c121dda003
diff -r 000000000000 -r f5bba12ef049 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 15 07:01:04 2015 +0000
@@ -0,0 +1,23 @@
+//スピーカーを鳴らすサンプルコード
+#include "mbed.h"
+
+#define mC 261.626 //「ド」の周波数
+
+//ピン設定
+PwmOut speaker(dp18);
+
+int main()
+{
+    //音を鳴らす
+    speaker.period(1.0/mC);
+    speaker = 0.5;
+
+    //5秒待つ
+    wait(5.0);
+    
+    //音を止める
+    speaker = 0.0;
+    
+    
+    while(true)
+}
\ No newline at end of file