Arduino dual Microphone Input VALUE weird

Hi,

I'm trying to get 0-1023 values from microphone inputs. But i only can get weird values like...
(2-7-8-30-134337630-2-4-7-3001223365400-3-7-300003)

So first, i'm wondering if this two products are the same. I'm using the first one.

First of all... are this products the same?

  1. http://www.ebay.com/itm/new-Sound-detection-sensor-module-sound-sensor-Intelligent-vehicle-for-Arduino-/110957479203?pt=LH_DefaultDomain_0&hash=item19d594c523

  2. http://www.ebay.com/itm/1pc-New-Analog-Sound-Sensor-Board-Microphone-MIC-Controller-For-Arduino-/300951969384?pt=LH_DefaultDomain_0&hash=item4612229e68

THANKS!

CODE:

int leftmicPin = 2;
int rightmicPin = 3;
int valLeft = 0;
int valRight = 0;
int directionVal = 0;

void setup() {
pinMode(leftmicPin, INPUT);
pinMode(rightmicPin, INPUT);
Serial.begin(9600);

}

void loop()
{
valLeft = analogRead(leftmicPin);
// valLeft = map (valLeft, 0,1023,0,179);
valRight = analogRead(rightmicPin);
// valRight = map (valRight, 0,1023,0,179);
directionVal = valRight - valLeft;
Serial.print(directionVal);
}

No matter what hardware you hook-up, your ADC readings should always be between 0 and 1023.

For troubleshooting purposes I recommend that you Serial.print your "raw" ADC readings before you map or subtract.

I would guess the problem is related to having no spaces between your "printed" values. I can see the minus sign when you get a negative after subtracting, but I don't know where that variable/value ends and a positive result begins...

Print one value on a line and print the variable name in front of the variable. (Sorry, my computer is acting "funny" ritht now and I can't access the Arduino language reference to help with that.)

I'm not sure what you are doing but with audio, you are going to get values that seem "random" when read one at a time. i.e. The right could be louder than the left, but the left might read higher at one instant where the right-waveform/phase is negative or near-zero.

Thanks for you words, but i'm afraid that the module i've bought (two of them... in same working condition) are just for... clap detection??

Anyway, i've used this code

int rightmicPin = 3;
int valRight = 0;

void setup() {
  Serial.begin(9600);      
}

void loop()
{
  valRight = analogRead(rightmicPin);
      
      Serial.print(valRight);   
  }

And from it i get a continuos string, not like a pot:

0231023102310231023102310231023272828282828282728282828282828272

The change comes when i move upwards the pot it contains... although it outputs the same value regard how much i move it....

      Serial.print(valRight);

Do a println. It's hard to tell if you are getting 0231 or 1023.

      Serial.println(valRight);

ehem.... THANKS Nick! so that's why i didn't get line carriage! ups

Anyway... after so much browsing... i think i got a module with only digital output... without analog output!

Will order a new one with analog.

Anyway... after so much browsing... i think i got a module with only digital output... without analog output!

I doubt that... But, when you buy something off eBay with no datasheet... Who knows WHAT you are getting?

A digital signal would be either logic 0 (about) 0V, or logic 1 (about ) 5V. In theory you would always read zero or 1023 with nothing in-between. In reality, you might read something slightly more than zero, and slighly less than 1023 (with some variation due to noise). You'd also get a reading in-between once in awhile if you happen to read the voltage when it's switching between one & zero.

[u]This one[/u] is biased at 2.5V so that you can capture the positive & negative half of the soundwave. With no sound, you'll read (about) 512. With quiet sounds, you will read values near 512. With loud sounds, you may get readings that go down to zero and up to 1023. But since it's a soundwave, with loud sounds you'll get "random" readings between zero and 1023, depending on where you are along the wave when you take a reading.