 # Frequency Measurement of a Guitar String.

Hi everybody,

So recently I have been using a frequency library to measure the frequency of a guitar string. I have wired up a guitar pickup to a 4th order low pass filter to isolate the fundamental frequency of the string. The signal then is passed through a comparator and finally to a voltage regulator. The end result is a square with a maximum voltage of 4V.

Here’s the link to the library if you are interested: FreqMeasure Library, for Measuring Frequencies in the 0.1 to 1000 Hz range, or RPM Tachometer Applications

Here is the code:

``````#include <FreqMeasure.h>

void setup() {
Serial.begin(57600);
FreqMeasure.begin();
}

double sum=0;
int count=0;

void loop() {
if (FreqMeasure.available()) {
count = count + 1;
if (count > 30) {
float frequency = FreqMeasure.countToFrequency(sum / count);
Serial.println(frequency);
sum = 0;
count = 0;
}
}
}
``````

Now the code works fine if the frequency is constant (e.g. input a frequency from a function generator). However, when I test it on the guitar I get a range of frequencies. Anything below 80 Hz is due to the transient nature of the string.

I want to add code so that the Arduino can pick out those 80 Hz as seen in the image and ignore all other printed values. I have attached the image below.

Any help would be greatly appreciated.

Thanks. Maybe average 10 readings, throwing out any data points more than 10% below the current average?

``````   float average = getFrequency();
for (int i=1; i<=10; ) {
float frequency = getFrequency();
if (frequency < (0.9 * (average/i)))
continue;  // Skip this sample
average += frequency;
i++;
}
``````

Have you researched FFT with arduino ?