Go Down

### Topic: Mic amps (Read 2650 times)previous topic - next topic

#### baum

#15
##### Apr 19, 2011, 03:35 pm
I have tried that, but I still get the constant reading. I'll try again.

#### baum

#16
##### Apr 19, 2011, 03:57 pm
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() {
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

#17
##### Apr 19, 2011, 04:22 pm
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.
--
I write books about Arduino and Electronics: http://simonmonk.org

#### baum

#18
##### Apr 19, 2011, 05:30 pm
OK. Thanks! But I only care about amplitude, why would I need filtering?

#### Si

#19
##### Apr 19, 2011, 05:38 pm
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
--
I write books about Arduino and Electronics: http://simonmonk.org

#### baum

#20
##### Apr 19, 2011, 06:19 pm
So I should make a hardware lowpass filter? What should I do?

#### Si

#21
##### Apr 19, 2011, 08:51 pm
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.

--
I write books about Arduino and Electronics: http://simonmonk.org

#22

#### Si

#23
##### Apr 19, 2011, 09:10 pm

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

--
I write books about Arduino and Electronics: http://simonmonk.org

Go Up

Please enter a valid email to subscribe