 # FFT in Arduino

I would like to implement FFT in Arduino UNO board. I used the FFT.h library from codebender website. When I try it along with ADC, I am not getting the required output. I need help. I want to know in what format will the FFT functions take input (like 1s and 0s?)?

The FFT library from OpenMusicLabs works very well, but the example provided there needs a bit of tweaking.

Here is a simple test case example that generates an input sample consisting of two sine waves, and then transforms it, verifying correct operation.

``````*
fft_test_sine
example sketch for testing the fft library.
This generates a simple sine wave data set consisting
of two frequences f1 and f2, transforms it, calculates
and prints the amplitude of the transform.
*/

// do #defines BEFORE #includes
#define LIN_OUT 1 // use the lin output function
#define FFT_N 64 // set to 64 point fft

#include <FFT.h> // include the library

void setup() {
Serial.begin(9600); // output on the serial port
}

void loop() {
int i,k;
float f1=2.0,f2=5.0;  //the two input frequencies (bin values)
for (i = 0 ; i < FFT_N ; i++) { // create samples
// amplitudes are 1000 for f1 and 500 for f2
k=1000*sin(2*PI*f1*i/FFT_N)+500.*sin(2*PI*f2*i/FFT_N);
fft_input[2*i] = k; // put real data into even bins
fft_input[2*i+1] = 0; // set odd bins to 0
}

fft_window();  //Try with and without this line, it smears

fft_reorder(); // reorder the data before doing the fft
fft_run(); // process the data using the fft
fft_mag_lin(); // calculate the magnitude of the output

// print the frequency index and amplitudes

Serial.println("bin  amplitude");
for (i=0; i<FFT_N/2; i++) {
Serial.print(i);
Serial.print("       ");
Serial.println(2*fft_lin_out[i]); //*2 for "negative frequency" amplitude
}
Serial.println("Done");
while(1); //wait here
}
``````