LED to music

I have a RGB LED and I have everything wired properly. I am looking for code that will make at least one LED go to music.

Here is some code I already have

 analogWrite(r,map(analogRead(A0),0,1023,0,255));

note I just have a audio signal connected directly to the analog input.

can some one recommend, create or teach me how to make an led blink to music nicely?

note I just have a audio signal connected directly to the analog input.

Audio data consists of positive and negative voltages. Supplying negative input to the Arduino is an excellent way to fry it.

You want:

  • Hardware *
    a) An amplifier to boost the audio signal to 0-5V
    b) A low-pass filter to cut out the high frequencies (just give you a "beat" signal) - can be combined with A
    c) Some way of removing the negative voltages so they don't overload your Arduino
  • or -
  • Software *
    a) Sample the audio for a short period into a buffer (may need an amplifier to boost it a little)
    b) FFT the data to give frequency buckets
    c) use the LED to display the value of one or more buckets of interest