Go Down

Topic: Mic amps (Read 1 time) previous topic - next topic

baum

I have tried that, but I still get the constant reading. I'll try again.

baum

nvrmnd. transistors were in backwards. Now, I get some fluctuation from 170~250, which you can see on a pwm'd led.


Edit: Just ran a high/low program:
Code: [Select]

int low = 1023;
int high = 0;
void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A3);
  if (sensorValue < low) {
    low = sensorValue;
  }
  if (sensorValue > high) {
    high = sensorValue;
  }
  Serial.print("h: ");
  Serial.print(high);
  Serial.print("\t");
  Serial.print("l: ");
  Serial.println(low);
}



And if I clap ~5 inches from mic I get h:939, l:40. So it works! yay!!

Si

Thats probably it working fine :)

As I said before, the fluctuation is the signal. If you want to get the overall level, you need to do some Integration / low pass filtering / averaging.

The sketch I pointed you at for the book, has an algorithm in it to LP filter.
--
My New Arduino Book: http://www.arduinobook.com

baum

OK. Thanks! But I only care about amplitude, why would I need filtering?

Si

A 1 KHz sound wave is an oscillation at 1000 times per second. Lets say a sine wave. So if you sample the amplitude you may hit it when its at a peak, or when its in a trough. But unless you do something like find the highest value, or low pass filter it to obtain the envelope, you will not have a measure of the 'volume' of the sound.

Words to lookup on Wikipedia: low pass filter, signal envelope, sine wave
--
My New Arduino Book: http://www.arduinobook.com

baum

So I should make a hardware lowpass filter? What should I do?

Si

Download the sketches for my book from http://www.arduinoevilgenius.com and have a look at the sketch for project 21. This has code for detecting the maximum level - if I remember right.

Then buy the book ;)
--
My New Arduino Book: http://www.arduinobook.com

baum

Where do I download the sketch?

Si

its on the downloads page ;)

You can just download the zip of all the sketches for the book.

--
My New Arduino Book: http://www.arduinobook.com

Go Up