I want to know if its possible to take an audio input from a mobile phone and as the frequency changes in real time to map that it a curtain color on the color spectrum of a PWM controlled RGB LED just using an analogue in pin and 3 PWM out pins. for instance 20Hz = Red and 20kHz = Blue and right in the center of that bandwidth = green. As that frequency changes I would like an Arduino nano to sample it at a quick rate and determine a color output. How would I code this :confused:
One simple way would be to Google "Arduino color organ" and look at some of the many ways it has been done before. Some are just based on volume but there are some frequency based versions around. Of course real music doesn't contain simple frequencies, a typical "note" may contain frequencies from 40Hz up to 15KHz or more.
Atached is a sketch I came across years ago and saved because it looked neat. It’s a Color Organ based on a Fast Fourier Transform done in fixed point math for speed. Note: The source page pointed to by the URL at the top of the sketch seems to no longer exist.
Color_Organ_FFT.ino (15 KB)