Hey, this is probably going to be a rookie question, but I am using the Arduino FHT library from ArduinoFHT - Open Music Labs Wiki in order to do frequency detection. I understand that you can output the data to a spectrum analyzer using a 3rd party application, but all I want to do is get like an integer value for the frequency.
Whenever I run the code below, I get a lot of data in the serial monitor, but nothing I can make sense of. (the code is mostly straight from one of the examples and I've been playing around with it)
Any thoughts on how I would simply get the frequency value? Or is my understanding flawed somehow?
Thanks
#define LOG_OUT 1 // use the log output function
#define FHT_N 256 // set to 256 point fht
#include <FHT.h> // include the library
void setup() {
Serial.begin(115200); // use the serial port
TIMSK0 = 0; // turn off timer0 for lower jitter
ADCSRA = 0xe5; // set the adc to free running mode
ADMUX = 0x40; // use adc0
DIDR0 = 0x01; // turn off the digital input for adc0
}
void loop() {
while(1) { // reduces jitter
cli(); // UDRE interrupt slows this way down on arduino1.0
for (int i = 0 ; i < FHT_N ; i++) { // save 256 samples
while(!(ADCSRA & 0x10)); // wait for adc to be ready
ADCSRA = 0xf5; // restart adc
byte m = ADCL; // fetch adc data
byte j = ADCH;
int k = (j << 8) | m; // form into an int
k -= 0x0200; // form into a signed int
k <<= 6; // form into a 16b signed int
fht_input[i] = k; // put real data into bins
}
//Serial.println(fht_input[0], fht_input[1]);
fht_window(); // window the data for better frequency response
fht_reorder(); // reorder the data before doing the fht
fht_run(); // process the data in the fht
Serial.println(fht_input[0], fht_input[1]);
//fht_mag_log(); // take the output of the fht
//Serial.println(fht_log);
sei();
//Serial.write(255); // send a start byte
Serial.write(fht_input[0]);
//Serial.write(fht_log_out, FHT_N/2); // send out the data
}
}