Frequency Detection

Hey ya'll,
I am new to this language and come from a background of software design, so I really need intro help. My project is to program the board to read frequency. How would I accomplish that?

Hardware:
Arduino Uno
Three cable microphone unit (no idea what the name is, but was told it will work).

Wiring:
I have the GND cable on the mic going to the GND position on the board.
I have the Vdd cable on the mic going to the 3.3V output position on the board.
I have the Out cable on the mic going to the A0 Analog In position on the board.

So is that correct?
What would be the programming like?

I really need someone to hold my hand through this project and help me through this. Thank you all so much!

Read this: Gammon Forum : Electronics : Microprocessors : Timers and counters

Frequency from a microphone? Forget it, unless the mike really is picking up a single frequency.

It might be. It might be one of those annoying bats that chirp all night when I am trying to sleep.

It might be one of those annoying bats that chirp all night when I am trying to sleep.

Hmmm. Chirping implies, at least to me, a non-constant frequency.

So it is impossible to pick up audio frequencies with a microphone? Although I am new, if the system is that limited, it is pathetic that it is regarded so highly.

Let's get some serious responses in here.

Reading that article and code, it sounds like it is set up for a different board than the Arduino UNO. Rather than input pin at D5, what could I utilize on the UNO?

AnonymousIP:
So it is impossible to pick up audio frequencies with a microphone? Although I am new, if the system is that limited, it is pathetic that it is regarded so highly.

Let's get some serious responses in here.

Easy there big fella. Let's start again.

AnonymousIP:
My project is to program the board to read frequency. How would I accomplish that?

"read frequency" doesn't mean an awful lot. Let's assume you get your mic correctly interfaced to an analog pin on an Arduino. Yes when you sing in to it, you'll get a load of different values on the analog pin. If that's all you want - you're done. However if you want to do more then you're going to need to specify what exactly before anyone can help.

AnonymousIP:
a background of software design

Then you should know the ropes of writing a requirement - yes?

It would be extremely useful to know what exactly said microphone would be monitoring. There's going to be a world of difference between identifying a simple 1KHz tone to the spectrum contained in human speech.

AnonymousIP:
Reading that article and code, it sounds like it is set up for a different board than the Arduino UNO. Rather than input pin at D5, what could I utilize on the UNO?

Why do you say that? Is this photo from that page not clear enough?

Input to the timer on pin 5. There is a big arrow pointing to it. The arrow goes through the word "Uno".

AnonymousIP:
So it is impossible to pick up audio frequencies with a microphone? Although I am new, if the system is that limited, it is pathetic that it is regarded so highly.

Look, I've seen videos of people using the Arduino as a (simple) spectrum analyzer, and yes, of audio frequencies. Let me find one for you ...

Here's one: https://www.youtube.com/watch?v=jJ7lzkrQIFk

One of my employees wrote this code although it does not seem to work on any pin past analog 3. It should be wired so that the electret microphone breakout board is wired to 3.3V to VCC, GND to GND, and the AUD to A1 and D2. Then for additional mics, AUD would go to A2 and D3 so on and so forth.

Code:

long count0,count1,count2,count3,count4;
long last;
double v0,v1,v2,v3,v4,voltage;

void bump0() {
count0++;
}
void bump1() {
count1++;
}
void bump2() {
count2++;
}
void bump3() {
count3++;
}
void bump4() {
count4++;
}

void setup() {
count0=0;
count1=0;
count2=0;
count3=0;
count4=0;
v0=0.0;
v1=0.0;
v2=0.0;
v3=0.0;
v4=0.0;
attachInterrupt(0,bump0,RISING);
attachInterrupt(1,bump1,RISING);
attachInterrupt(2,bump2,RISING);
attachInterrupt(3,bump3,RISING);
attachInterrupt(4,bump4,RISING);
last=millis();
Serial.begin(9600);
Serial.println("millis,f0(Hz),v0(v),f1(Hz),v1(v),f2(Hz),v2(v),f3(Hz),v3(v),f4(Hz),v4(v)");
}

void loop() {
long next=millis();
if (next-last>100) {
long c0,c1,c2,c3,c4;
c0=count0;
count0-=c0;
c1=count1;
count1-=c1;
c2=count2;
count2-=c2;
c3=count3;
count3-=c3;
c4=count4;
count4-=c4;
double dt=(next-last)/1000.0;
Serial.print(next-last);
Serial.print(',');
Serial.print(double(c0)/dt);
Serial.print(',');
Serial.print(v0);
Serial.print(',');
Serial.print(double(c1)/dt);
Serial.print(',');
Serial.print(v1);
Serial.print(',');
Serial.print(double(c2)/dt);
Serial.print(',');
Serial.print(v2);
Serial.print(',');
Serial.print(double(c3)/dt);
Serial.print(',');
Serial.print(v3);
Serial.print(',');
Serial.print(double(c4)/dt);
Serial.print(',');
Serial.println(v4);
v0=0.0;
v1=0.0;
v2=0.0;
v3=0.0;
v4=0.0;
last=next;
} else {
voltage=5.0*(double)abs(analogRead(0)-512)/1024.0;
if (voltage>v0) v0=voltage;
voltage=5.0*(double)abs(analogRead(1)-512)/1024.0;
if (voltage>v1) v1=voltage;
voltage=5.0*(double)abs(analogRead(2)-512)/1024.0;
if (voltage>v2) v2=voltage;
voltage=5.0*(double)abs(analogRead(3)-512)/1024.0;
if (voltage>v3) v3=voltage;
voltage=5.0*(double)abs(analogRead(4)-512)/1024.0;
if (voltage>v4) v4=voltage;
}
}

What seems to be wrong with it?

What seems to be wrong with it?

Too many external interrupts for a Uno?
No code tags?
Slow serial?

void setup() {
  count0=0;
  count1=0;
  count2=0;
  count3=0;
  count4=0;

Poor understanding of C?

AWOL:
Too many external interrupts for a Uno?
No code tags?
Slow serial?

void setup() {

count0=0;
  count1=0;
  count2=0;
  count3=0;
  count4=0;


Poor understanding of C?

Yeah, that last part is rubbish as they start with 0 or NULL value.

Could you explain the external Interrupts to me, that is something I have zero experience with. Thanks

Yeah, that last part is rubbish as they start with 0 or NULL value.

And they should be in arrays.

The Uno has two external interrupts, but they've got zilch to do with analogue inputs, so it's unclear what the code is supposed to be doing.

yeah, you and me both are confused by this code. The odd thing, it seems to work when comparing the inputs to this tone generator., but only for the first 2 analog inputs

Do some reading at Nick Gammon's Interrupt page

You can have a PCINT on any '328P pin, or limit yourself to the 2 external interrupts.

Which Arduino do you have?

How to use this forum