simple voice recorder. Pwoer up or reset, record voice for 5 sec. Press botton then voice out.

Dependencies:   mbed

/media/uploads/hayama/2014-08-11_20.21.54.jpg

Revision:
0:00a8ac955304
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 14 09:45:57 2014 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#define NUMDAT 15000
+#define DLY 250
+
+float micCB;
+short dat[NUMDAT];
+int i;
+ 
+DigitalIn sw(p5); 
+AnalogIn micC(p16);     
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 );  
+
+void voiceOut(){
+    leds=2;
+    for(i=0;i<NUMDAT; i++){
+        spOut=((float)dat[i])/32768*10+0.5; 
+        wait_us(DLY);
+    }
+}
+
+int main() {
+    leds=0;
+    wait(1);
+    micCB=0;
+    for(i=0;i<100;i++){ micCB+=micC; } 
+    micCB/=100;
+    leds=1;
+    
+    // record voice
+    for(i=0;i<NUMDAT; i++){
+        dat[i]=(int)((micC-micCB)*32768);
+        wait_us(DLY);
+    }
+   
+    while(1){
+        leds=0;
+        if (sw==0) voiceOut();
+    }
+}
+
+
+