Tadao Iida
/
VoiceRecorder
ハイパー・マイコン mbedでインターネット 電子工作 4章 リスト4-1 VoiceRecorderのプログラム
Revision 0:d9e4d33de26d, committed 2014-07-11
- Comitter:
- sunifu
- Date:
- Fri Jul 11 14:20:25 2014 +0000
- Commit message:
- 2014.07.11
Changed in this revision
diff -r 000000000000 -r d9e4d33de26d TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Fri Jul 11 14:20:25 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r 000000000000 -r d9e4d33de26d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 11 14:20:25 2014 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "TextLCD.h" + +AnalogIn in(p20); +AnalogOut out(p18); +DigitalIn playsw(p21) ; +DigitalIn recordsw(p22); + +DigitalOut led1(LED1); +DigitalOut led4(LED4); + +TextLCD lcd(p24, p26, p27, p28, p29, p30); + +#define N 13000 +unsigned short buf[N]; + +void read(void) { + int i; + for ( i = 0 ; i < N ; i++ ){ + buf[i] = in.read_u16(); + wait(0.0002); + } +} + +void write(void) { + int i; + for ( i = 0 ; i < N ; i++ ){ + out.write_u16(buf[i]) ; + wait(0.0002); + } +} + + +int main() { + while(1) { + if ( recordsw == 1 ){ + lcd.locate(0,0) ; + lcd.printf(" --- Record --- "); + led1 = 1; + read() ; + led1 = 0; + lcd.cls( ) ; + } + if ( playsw == 1 ){ + lcd.locate(0,0) ; + lcd.printf(" --- Play --- "); + led4 = 1 ; + write(); + led4 = 0 ; + lcd.cls( ) ; + } + } +}
diff -r 000000000000 -r d9e4d33de26d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jul 11 14:20:25 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd \ No newline at end of file