serial read electret mic


i using pre-amp circuit , electret mic sound sensor.  assuming circuit correctly installed, code must @ fault because data not changing more -/+ 1 or 2 figures. please advise problem.


int micpin = 0;
int val;



void setup() {

 serial.begin(9600);

 pinmode (micpin, input);


}

void loop () {
 val = analogread (micpin);
 val = val/5;
 serial.println(val);
 delay (500);


}

first minor point. don't need pinmode (micpin, input);
in setup function because needed setting digital pins. tha analogread function handles configuring pin mode.

more major point. audio signal ac voltage. arduino analog input pin can handle signals in 0-+5vdc range, no negitive voltages allowed. audio voltage levels need rectified , filtered able give decent average level of audio signal. taking 1 audio sample every 1/2 second not going give meaning full audio signal level information, random values.

lots of problems attempting do. there electrical analog signal processing needed make useful measurement.

eventual usage of signal measurement, want measurement once have processed it?

it's easy built 'clap detector' type noise switch more envolved using audio level measuement signal needs thought , design details.

one thing migh try change arduino's analog reference use internal 1.1volt reference. have same effect amplifiying input signal x5. mic simple preamp outputs around 1 volt max peak.
http://arduino.cc/en/reference/analogreference

good luck

lefty




Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > serial read electret mic


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums