Finalmente tive tempo para continuar com esta investigação que se tem vindo a arrastar, mas que estou a obter bons resultados :)
Trata-se de um sensor de volume sonoro, o circuito que usei é este: http://www.rev-ed.co.uk/docs/picaxe_sound.pdf (http://www.rev-ed.co.uk/docs/picaxe_sound.pdf)
Estou a usar microfones que tinha aqui para casa de uns headsets partidos:
(https://lusorobotica.com/proxy.php?request=http%3A%2F%2Ffarm4.static.flickr.com%2F3584%2F3497277414_eff0b1d252.jpg%3Fv%3D0&hash=d3c242de08b947cf479efd2779c6aa78e55e1adc)
No seu interior podemos ver que se tratam de microfones do tipo electrec
(https://lusorobotica.com/proxy.php?request=http%3A%2F%2Ffarm4.static.flickr.com%2F3332%2F3496461163_701fff777f.jpg%3Fv%3D0&hash=221575649d7e0e343cfafb79d8428f68dfa62c28)
O circuito
(https://lusorobotica.com/proxy.php?request=http%3A%2F%2Ffarm4.static.flickr.com%2F3335%2F3496460749_877a2af1b2.jpg%3Fv%3D0&hash=03effe660212708eeb92878494120f8db11792ce)
Detalhe do circuito. Estou a usar um condensador de 10uF para estabilizar o sinal de output. É o condensador verde que se encontra mais à direita.
Não me consigo imaginar a soldar estes componentes todos quatro vezes numa pcb, já que gostava de ter uma aplicação com pelo menos quatro microfones.... :)
(https://lusorobotica.com/proxy.php?request=http%3A%2F%2Ffarm4.static.flickr.com%2F3656%2F3496460969_d6f3e8e836.jpg%3Fv%3D0&hash=8acc04fd5facc8d1dd165a4ece8adb8ce424cb7f)
E aqui um video com um sketch em processing para vizualizar os dados recebidos pelo arduino:
http://www.flickr.com/photos/guibot/3497408152/#secret8980785104-w500-h375 (http://www.flickr.com/photos/guibot/3497408152/#secret8980785104-w500-h375)
E o respectivo código:
/* ****************************************************
Arduino Code
**************************************************** */
int analogValue;
int val;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// read analog input
analogValue = analogRead(0);
// send values to processing
Serial.println(analogValue, DEC);
// pause for 10 milliseconds:
delay(10);
}
/* ****************************************************
Processing Code
**************************************************** */
// import the Processing serial library
import processing.serial.*;
// declare a font variable
PFont font48;
int linefeed = 10; // Linefeed in ASCII
Serial myPort; // The serial port
// value recieved from the serialport / arduino
int sensorValue;
// mapped value
float sensorValueMap;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Setup
void setup() {
myPort = new Serial(this, Serial.list()[0], 9600);
// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(linefeed);
size (800, 600);
background (0);
//smooth();
// you need to have this font in your machine, if not go to
// Tools - Creat Font - and create your own font
font48 = loadFont("alask_48.vlw");
textFont(font48);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Serial Event
void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil(linefeed);
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
//println(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ','));
// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
//print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\n");
// sensor
sensorValue = sensors[0];
//sensorValueSmooth = sensors[1];
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Draw
void draw() {
// set the black backgrounf
background(0);
// run the displayText() function
displayText();
// map the recieved values
sensorValueMap = map(sensorValue, 0, 1024, 0, 800);
// draw a rectangle based on the variable sensorValueMap
rect (0, 100, width, sensorValueMap);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display Text
void displayText() {
text("Sensor Value", 20, 80);
text(sensorValue, 450, 80);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Save image
void keyPressed(){
if(key=='s')
saveFrame("sound-######.png");
}