Hello, I am trying to have a signal come into the Arduino at A0 and have the max frequencies display in the serial monitor. I have read the signal in an oscilloscope and can see that it does have a sinusoidal waveform.

what would I change in this code in order to do that?

/*

Example of use of the FFT libray

Copyright (C) 2014 Enrique Condes

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program. If not, see http://www.gnu.org/licenses/.

*/

/*

In this example, the Arduino simulates the sampling of a sinusoidal 1000 Hz

signal with an amplitude of 100, sampled at 5000 Hz. Samples are stored

inside the vReal array. The samples are windowed according to Hamming

function. The FFT is computed using the windowed samples. Then the magnitudes

of each of the frequencies that compose the signal are calculated. Finally,

the frequency with the highest peak is obtained, being that the main frequency

present in the signal. This frequency is printed, along with the magnitude of

the peak.

*/

#include "arduinoFFT.h"

arduinoFFT FFT = arduinoFFT(); /* Create FFT object */
/*

These values can be changed in order to evaluate the functions

*/*

const uint16_t samples = 64; //This value MUST ALWAYS be a power of 2

const double signalFrequency = 1000;

const double samplingFrequency = 5000;

const uint8_t amplitude = 100;

/

const uint16_t samples = 64; //This value MUST ALWAYS be a power of 2

const double signalFrequency = 1000;

const double samplingFrequency = 5000;

const uint8_t amplitude = 100;

/

These are the input and output vectors

Input vectors receive computed results from FFT

*/

double vReal[samples];

double vImag[samples];

#define SCL_INDEX 0x00

#define SCL_TIME 0x01

#define SCL_FREQUENCY 0x02

#define SCL_PLOT 0x03

void setup()

{

Serial.begin(115200);

Serial.println("Ready");

}

void loop()

{

/* Build raw data */
double cycles = (((samples-1) * signalFrequency) / samplingFrequency); //Number of signal cycles that the sampling will read
for (uint16_t i = 0; i < samples; i++)
{
vReal *

*= int8_t((amplitude * (sin((i * (twoPi * cycles)) / samples))) / 2.0);/*Build data with positive and negative values*/

*//vReal*

*= uint8_t((amplitude * (sin((i * (twoPi * cycles)) / samples) + 1.0)) / 2.0);/* Build data displaced on the Y axis to include only positive values*/**_ vImag*

* }

*= 0.0; //Imaginary part must be zeroed in case of looping to avoid wrong calculations and overflows** }

*Serial.println("Data:");*

*/*Print the results of the simulated sampling according to time*/**_**PrintVector(vReal, samples, SCL_TIME);**FFT.Windowing(vReal, samples, FFT_WIN_TYP_HAMMING, FFT_FORWARD); /*Weigh data*/**_*Serial.println("Weighed data:");*_**PrintVector(vReal, samples, SCL_TIME);**FFT.Compute(vReal, vImag, samples, FFT_FORWARD); /*Compute FFT*/**_*Serial.println("Computed Real values:");*_**PrintVector(vReal, samples, SCL_INDEX);**_*Serial.println("Computed Imaginary values:");*_**PrintVector(vImag, samples, SCL_INDEX);**Serial.println("Computed magnitudes:");*

*_ FFT.ComplexToMagnitude(vReal, vImag, samples); /*Compute magnitudes*/**_**PrintVector(vReal, (samples >> 1), SCL_FREQUENCY);**_*double x;*double v;*

*FFT.MajorPeak(vReal, samples, samplingFrequency, &x, &v);*

*Serial.print(x, 6);*

*Serial.print(", ");*

*Serial.println(v, 6);*

*}*

*while(1); /*Run Once*/**// delay(2000); /*Repeat after delay*/**{*

*void PrintVector(double *vData, uint16_t bufferSize, uint8_t scaleType)**_**for (uint16_t i = 0; i < bufferSize; i++)**_*{*double abscissa;*

*switch (scaleType)*

*/*Print abscissa value*/**{*

*_**case SCL_INDEX:**break;*

*_ abscissa = (i * 1.0);**_**case SCL_TIME:**break;*

*_ abscissa = ((i * 1.0) / samplingFrequency);**_**case SCL_FREQUENCY:**break;*

*_ abscissa = ((i * 1.0 * samplingFrequency) / samples);**}*

*Serial.print(abscissa, 6);*

*_**if(scaleType==SCL_FREQUENCY)**_*Serial.print("Hz");*Serial.print(" ");*

*Serial.println(vData*, 4);*}**Serial.println();**}*_*