Frequency Spectrum Analyzer – Overview

     The purpose of our project was to create a Frequency Spectrum Analyzer that receives an analog input via a 3.5mm audio jack and shows the frequencies of the signal on a board of 60 LEDs. The fourier transform converts audio output frequencies back into the original input frequencies and was implemented via the fix_fft library for Arduino.
     The first step of programming was to test the LEDs with example code from Adafruit, the company that manufactures them. This strandtest program includes functions such as color flush which lights each LED in sequence to a given color with a delay between each illumination of the LEDs. Once the LEDs were proven to be functional, the LED enclosure was built (here is the strand test with the enclosure) and analog signal testing was begun. First, the 3.5mm auxiliary jack’s right channel was connected through a 3.5mm breakout adapter to the analog 0 port, then the jack’s sleeve was connected to the ground of the board. To process the signal, the 1024 analog samples were sent as an array through the fix_fft function within the fix_fft library. 10 samples were taken from the output of the fft and sent to the terminal to verify functionality. Here an issue was discovered. If the analog reference value is not set, the output will show signal noise due to floating values. This problem was fixed by adding analogReference(DEFAULT) to the setup function.
     To display the fft output values, a setBar function was created. This function receives the value for which frequency column to modify and the data for that frequency set. If the input data value is above the threshold for a given column, the LEDs will light up vertically indicating how strong the frequency is at that position. For instance, if the threshold is 15 and the column is 1, the third LED will light up with a value of data greater than 45 (15*3). To set the color of the LEDs, the setPixelColor(n,color) function was used. The bottom row’s color is set to green with a gradient reaching red at the top row. After each iteration through all received analog data, all LEDs are cleared until new data is received. This completes the cycle for spectrum conversion and displaying the data.