As a test of the audio amplifier, it is a test to make a sound effect in the program. オーディオアンプのテストとして、プログラムで効果音を作るテストです。

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jksoft
Date:
Mon May 12 13:52:38 2014 +0000
Commit message:
First edition

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 May 12 13:52:38 2014 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+
+AnalogOut DACout(p18);
+DigitalOut AMPEnable(p12);
+DigitalIn SW1(p25);
+DigitalIn SW2(p26);
+
+void wave(float volume , float fq , float time)
+{
+    float w_time = 1.0 / fq;
+
+    AMPEnable = 0;
+    for (float i=0; i<time / w_time; i++) {
+        DACout = volume;
+        wait(w_time/2);
+        DACout = 0.0;
+        wait(w_time/2);
+    }
+    AMPEnable = 1;
+    
+}
+
+int main() {
+    SW1.mode(PullUp);
+    SW2.mode(PullUp);
+
+    while(1)
+    {
+        if( SW1 == 0 )
+        {
+            for( int i = 0 ; i < 10 ; i++ )
+            {
+                wave( 0.2 , i * 500.0 , 0.2 );
+            }
+        }
+        if( SW2 == 0 )
+        {
+            wave( 0.2 , 2000.0 , 0.2 );
+            wave( 0.2 , 1000.0 , 0.2 );
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 12 13:52:38 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file