reading analog voltage

I have tested an LM386 circuit with multimeter and speaker so I know the thing works but I can't seem to make the analog pin read anything meaningful with this code

void setup() {
   Serial.begin(9600);
}

void loop() {
  
  int soundLevel =  analogRead(0) -512;
  
  Serial.print( "soundIn = ");
  Serial.println(soundLevel);
 delay (1000);
}

Surely this is something simple I have overlooked.

Just curious,
what is the analogRead inputting?

And do you have the grounds connected? It's been a while since I've worked with the 386, but here's a link I found.. some explanations that might help.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249854253

Just skimming over the post, somebody said something about it outputting AC voltage, which may be what's happening.

Good luck!:smiley:

Here is the schematic http://itp.nyu.edu/physcomp/sensors/Reports/CondenserMicrophones I haven't included the bridge rectifier yet. Do you think this is necessary?

Hi, francalzia

What indeed means "nothing meaningful" ? Give us some values, pls.
Don't worry, if they look random numbers between -512 and 511 :wink: .
Beware, the voltmeter has an internal rectifier, that is the reason why it can show something "meaningful".

Regards,
thenoble66

I haven't included the bridge rectifier yet. Do you think this is necessary?

Yes, all the components shown are needed. An Arduino analog input pin is designed to only safely measure DC voltages in a 0 to +5vdc (no negative voltages allowed). Sense audio is a form of AC voltages, the post amplifier components are shown to scale and convert the AC audio to a variable DC voltage that a Arduino A/D pin can safely read.

Lefty

Thanks for the help. I finally got this up and running.