Pages: 1 [2]   Go Down
Author Topic: Mic amps  (Read 1575 times)
0 Members and 1 Guest are viewing this topic.
Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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!!
Logged

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats probably it working fine smiley

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

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

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink
Logged

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

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where do I download the sketch?
Logged

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

its on the downloads page smiley-wink

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

Logged

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

Pages: 1 [2]   Go Up
Jump to: