- 2011-06-16 (木)
最も怠惰な方法。
秋月で売ってるアンプ内蔵マイク SP0103NC3-3 を使ってみます。
こんなふうに配線。
0.1µFをこんなふうに付けてください。0.47µFを持ってたらそっちの方がいいです。
線の色は
赤 V+
白 信号
黒 GND
です。お願いします。
Arduinoの5V、GND、A0につなぐ
Arduino側で電圧を読み込んでシリアルで出力
void setup() {
Serial.begin(9600) ;
}
void loop() {
int in = analogRead(0) ;
Serial.println(in) ;
delay(10) ;
}
Processingで受けて、グラフをプロット
import processing.serial.*;
Serial p ;
int x, y, yPrev ;
void setup() {
size(400,300) ;
p = new Serial(this, Serial.list()[0], 9600) ;
p.bufferUntil(10) ;
}
void draw() {
line(x-1, yPrev, x, y) ;
if (++x >= width) {
background(200) ;
x = 0 ;
}
}
void serialEvent(Serial p) {
String str = p.readString() ;
int val = int(trim(str)) ;
yPrev = y ;
y = int(map(val, 0, 1024, height, 0)) ;
}
センサの挙動の雰囲気を知るには、グラフにするといいと思います。
コンソールで数値をみただけでは分からない空気感が読めます。
あとは各自工夫されたし。おわり
- Newer: A4A WS 1日目
- Older: EAGLEでプリント基板にゲバラを描く方法