Electret microphone into LED values

Hey guys I am trying to make a banjo that lights up different color depending on the note played. Needless to say I am a new guy have some problems and need some help.

First is I want to get and avarage reading of the signal off the microphone value but can't figure it out.

Second if at all posible I would love to make the arduino be able to read what note is being played, not just how loud it is. Is there a way to do that in arduino or do I need to run it through Processing? If so, how do I do that?

here is my code, thanks for the help.

int mic = 0;
int micVal = 0;
int led = 9;

void setup()
{
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}

void loop()
{
  mic = analogRead(micVal);              //read the value of the micVal pin
mic = map(mic, 500, 1023, 0, 255);       //map it to a value that is readable by an LED

mic = abs(mic);                          //get absolute value for the mic value

analogWrite(led, mic);                   //write the value to an LED

  Serial.println(mic);                   //print the value so I can read it
}

I'm looking into trying to use some of QuantSuff's code for my own use here shortly. I haven't looked at it deeply though so here is the link to garner what you can from it. Maybe some of his work may be of use to you. http://www.instructables.com/id/S42CQ3NFT7PR5RG/

You might also be interested in the snippet I use to load from a microphone for the sketch mentioned above.

Since analogRead takes up to 110uS to return, the best frequency determination response is around 5KHz. Post processing will probably need to be short and limited to integers to maintain any accuracy.

#define samplesize 10

int input[samplesize];
.
.
.

/* Routine to read input from an amplified mic.
 * requires analogReference(INTERNAL);
 * (c) 2009 qs@quantsuff.com
 */

int getInput() {
  int iMin=600;
  int iMax=0;
  int ii=analogRead(micPin);
  for (int i=0;i<3;i++) { // Minimum 3
    ii=analogRead(micPin);
    iMax=max(iMax,ii);
    iMin=min(iMin,ii);
  }
  inSum+= iMin-input[inIdx]; // Find baseline noise/offset.
  input[inIdx]=iMin;
  inIdx++;
  if (inIdx>=samplesize)
    inIdx=0;
  return max(iMax-(inSum/samplesize),0);
}

Are you using an amplifier between the mic and the Arduino?

Don't expect sensible results if you're not!

As to note detection, it's tricky. Google "Goertzel's algorithm"

It's not an easy thing to do. The best I have come across is this link:-

http://registeringdomainnamesismorefunthandoingrealwork.com/blogs/?p=150