Go Down

Topic: Electret Microphone (Read 1 time) previous topic - next topic

sid_muthal

I'm kind of new to audio with arduino and I wanted to get data from my electret microphone. I tried using a basic circuit (picture posted below) that I found online. However, when I use this, all I get as an output is 1023. There is no fluctuation what so ever. I'm also using this code to test it.

int sensorPin = A0;    //Microphone Sensor 'ANALOG' pin on Arduino
int aLED = 13;   

int sensorValue = 0;

void setup() {
  pinMode(aLED, OUTPUT);
  Serial.begin(9600);
}

void loop() {

  sensorValue = analogRead(sensorPin);   
Serial.println(sensorValue);

  if (sensorValue<869){
    digitalWrite(aLED, HIGH);

    delay(20); 
} else {
    digitalWrite(aLED, LOW);

}
}

Can someone help me?



Magician

Can you put more details on hardware, what kind of transistor, cap and resistors ?

sid_muthal

Transistor is a 2N3906
Cpacitor is a .1 uF
2 of the resistors that have the same color bands are each 10 K ohm resistor
the final resistor is a 100 K ohm resistor.

Magician

2N3906 is PNP, but wiring looks for NPN,
Option: change to 2N3904 or 2N2222.
   change wiring, you can get it works with reverse polarity and switching E - C compare what you have now

sid_muthal

Thanks alot that's what did it! Also another question. on all forums i've read, when an input is given to the electret microphone, the value on the serial reader should go down (usually around 860 and the 750-800 when blown on) how ever with this set up, im getting about 136 when its in a silent room and it actually spikes up to about 900 when blown on lightly. When its receiving input, is it increasing it's impedance?

Magician

It's can go ether way, up or down. Analog input reading AC voltage (with DC offset).
Read at wiki how to calculate :
http://en.wikipedia.org/wiki/Alternating_current#Power_and_root_mean_square

sid_muthal

Alright thanks alot. One last thing. When i do get readings its not very consistent. If i blow into the mike it spike really high but if you look at the serial read it rapidly shifts from 900 to bewteen 30 and 40 so when i test it with the LED, it flickers. Any idea how to fix this? Also 130-900 is a huge jump for blowing on it lightly, how to i make it a little less sensitive so i can really control something with sound?

Magician

arduino IDE has an File / Example / 03 Analog / Smoothing. study how it works.
Than find this line:
Code: [Select]
  // read from the sensor: 
  readings[index] = analogRead(inputPin);
and change it to:
Code: [Select]
  // read from the sensor: 
  readings[index] =  (analogRead(inputPin) - 136);
  readings[index] = readings[index] * readings[index];
136 - is a value you are reading in silence

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview