Page 1 of 1

reading voltage from analog pin

Posted: Sat Oct 03, 2009 2:02 pm
by keithg
I have tested an LM386 circuit with multimeter and a small speaker so I know it is functional but I can't read meaningful values with this code
Code: Select all
void setup() {
   Serial.begin(9600);
}

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

I would appreciate advise.  Thanks.

Posted: Tue Oct 06, 2009 6:49 am
by Liencouer
What are you trying to accomplish? How is the speaker/audio amp related to the analog input? What do you have hooked up to analog pin 0?