Trying to figure out how to use this library FreqMeasure, on Arduino first and then Teesy. Example code below. Where do I tell it what input pin is used?
Ultimately trying to build a guitar tuner. I'm currently using an older frequency measure code, this one seems better. I've applied a voltage offset to get the input signal into the range.


#include <FreqMeasure.h>

void setup() {

double sum=0;
int count=0;

void loop() {
  if (FreqMeasure.available()) {
    // average several reading together
    sum = sum +;
    count = count + 1;
    if (count > 30) {
      float frequency = FreqMeasure.countToFrequency(sum / count);
      sum = 0;
      count = 0;
Last edited by a moderator:
Look at the library source code, at FreqMeasureCapture.h

Don't know which teensy you are using, but for example for Teensy 4.x I see:
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
#define CAPTURE_USE_FLEXPWM4_CH0A 22 // FlexPWM CH0-A is pin 22

Looks like it needs to be pin 22.

you might look at the FreqMeasureMulti library, You have a lot more choices in which pin to use.
See it's readme file.
Maybe this would capture it:

// Arduino Uno, Duemilanove, LilyPad, Mini, Fio, etc
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
#define CAPTURE_USE_TIMER1 // ICP1 is pin 8
So pin 8... is that D5?!? According to this schematic?

This is the pin out from Arduino
They confuse things by counting from 1 on both sides, but using the normal IC pin numbering, starting from top left, running down the left side and then back up the right side, pin 8 is showen as D5.

Perhaps you should ignore all that I said above.
Here is a picture of the Nano with pin functions on.
To clarify to yourself you could do a "Blink" on your desired pin and see if it goes UP-Down-UP-DOWN....
Last edited:
D8 is ICP1 (mentioned in the code comment and used to capture timer events). That's what the library expects to be used.