Pages: [1]   Go Down
Author Topic: Electret Microphone  (Read 934 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?




* Electret_setup.jpg (709.53 KB, 2463x1007 - viewed 79 times.)
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2566
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2566
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2566
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2566
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: