Vu meter help

I’m attempting to make a a vu meter. when I have the mic hooked up to my arduino and read the values off the serial i get appropriate values.but then when I have it turn on on off my row of LEDs the value my mic is returning will only jump between high and low even in a silent room. for reference the mic returns a signal of about 500 in a quite room and the max will be about 900. but when it jumps between its high and low it gives values of 850 and 100.

int ledPins[]={2,3,4,5,6,7,8,9};
void setup(){
  for(int i=0;i<8;i++){
    pinMode(ledPins[i],OUTPUT);
  }
  Serial.begin(9600);
}  
void loop(){
  int sensorReading  = analogRead(A0);
  delay (10);
  int lon=;
  Serial.println(sensorReading);
     Serial.println(lon);
      Serial.print('\n');
switch (lon){
case 7:
    for(int t=0;t<8;t++){digitalWrite(ledPins[t],HIGH);}
    break;
case 6:
    for(int t=0;t<7;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>6;r--){digitalWrite(ledPins[r],LOW);}
    break;
case 5:
    for(int t=0;t<6;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>5;r--){digitalWrite(ledPins[r],LOW);}
    break;
case 4:
    for(int t=0;t<5;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>4;r--){digitalWrite(ledPins[r],LOW); }
    break;
case 3:
    for(int t=0;t<4;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>3;r--){digitalWrite(ledPins[r],LOW);}
    break;
case 2:
    for(int t=0;t<3;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>2;r--){digitalWrite(ledPins[r],LOW);}
    break;
case 1:
    for(int t=0;t<2;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>1;r--){digitalWrite(ledPins[r],LOW);}
    break;
case 0:
    for(int t=0;t<1;t++){digitalWrite(ledPins[t],HIGH);}
    for(int r=7;r>0;r--){digitalWrite(ledPins[r],LOW);}

  break;
default:
   for(int i=0;i<8;i++){digitalWrite(ledPins[i],LOW);}
   break;
      }
delay(100);
}

What kind of mic are you using and how did you connect it? Would you please show us the schematic?

BTW: here is how I implemented a VU meter http://blog.blinkenlight.net/experiments/basic-effects/vu-meter/. This way I avoided all mic issues.

Yes it will jump between high and low values because it is reading the audio waveform. The louder it is the bigger both the positave and negitave readings get. You need a peak detector in front of the input.

[quote author=Udo Klein link=topic=86205.msg646108#msg646108 date=1326100691] What kind of mic are you using and how did you connect it? Would you please show us the schematic?

BTW: here is how I implemented a VU meter http://blog.blinkenlight.net/experiments/basic-effects/vu-meter/. This way I avoided all mic issues. [/quote]

http://lowvoltage.wordpress.com/2011/05/15/lm386-mic-amp/

This is what I used for an amp

As for the mic reading high and low values it works fine when no LEDs are attached.

Have you wired resistors in series with leds? Could provide drawings?