I wanted to do this project of a visual balancer with 8x8 LED matrix and sound sensor, but the code doesn't work... Would you help me?
#include <ArduinoFFT.h> // Assicurati di includere la libreria corretta
#include <LedControl.h> // Libreria per controllare il display a matrice
#define DATA_IN 12
#define CLK 11
#define CS 10
ArduinoFFT FFT = ArduinoFFT();
LedControl lc = LedControl(DATA_IN, CLK, CS, 1);
void setup() {
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
Serial.begin(9600);
}
void loop() {
double vReal[128];
double vImag[128];
// Leggi i valori dal sensore sonoro
for (int i = 0; i < 128; i++) {
vReal[i] = analogRead(A2);
vImag[i] = 0;
}
// Esegui l'analisi FFT
FFT.Windowing(vReal, 128, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
FFT.Compute(vReal, vImag, 128, FFT_FORWARD);
FFT.ComplexToMagnitude(vReal, vImag, 128);
// Visualizza l'equalizzatore sul display a matrice
displayEqualizer(vReal);
}
void displayEqualizer(double *vReal) {
lc.clearDisplay(0);
for (int i = 0; i < 8; i++) {
int value = map(vReal[i], 0, 1023, 0, 8);
lc.setRow(0, i, (1 << value) - 1);
}
}
C:------
fatal error: ArduinoFFT.h: No such file or directory #include <ArduinoFFT.h> // Assicurati di includere la libreria corretta
^~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: ArduinoFFT.h: No such file or directory
You will need to download and install the correct version of the library.
Start with the built in library examples, as the latest version of that library changed some naming conventions (lower case 'A' in the library name, for one).
I downloaded the library from the link, but the error is the same:
C:---------
fatal error: arduinoFFT.h: No such file or directory
#include <arduinoFFT.h>
^~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: arduinoFFT.h: No such file or directory
Also... an example in the library shows this object creation: (edit: more complete example)
const uint16_t samples = 64; //This value MUST ALWAYS be a power of 2
const float samplingFrequency = 100; //Hz, must be less than 10000 due to ADC
unsigned int sampling_period_us;
unsigned long microseconds;
/*
These are the input and output vectors
Input vectors receive computed results from FFT
*/
float vReal[samples];
float vImag[samples];
/* Create FFT object with weighing factor storage */
ArduinoFFT<float> FFT = ArduinoFFT<float>(vReal, vImag, samples, samplingFrequency, true);