Go Down

Topic: Frequency Counter Library (Read 47555 times) previous topic - next topic


I use the frequency library on both Mega ADK ( modified library)  and Nano board.
When i measure a precise 1.000.000 Hz signal I get 1.000.169 on the display.
I try to correct this with f_comp but it seems that i can only increase the displayed reading.
How can I decrease the reading to 1.000.000 ??

Thanks for a nice frequency library. Very usefull.


Hello dc42.

I just tested your improved version of a frequency counter sketch (Reply#35).
http://forum.arduino.cc/index.php?PHPSESSID=25artcic6a44jl71kf4a1kevo7&topic=64219.30 .
It works great!. Is is possible to modify it to read frequencies between 1Hz to 3Hz. So far, I can measure with your code frequencies over 2.99Hz.

Thank you.


Can I detect a guitare sound frequency with it?


Can anyone help me?

I have a bipolar signal from 40mVp to 4Vp (it has 2Kohm impedance too as it comes from an inductance). I want to measure his frecuency. I tried all configurations possible withouth succesful.

My first approach was plug into V+ and V- in an operational with open loop (so i have an square output and a single edge detector with a timer will measure). The output is not consistent due to the small voltage of the signal i guess.

I tried a transistor with the signal attached to the base and collector so it enables. It does not work either. The solution with the biestable is not possible due to the small Voltage of the signal when low frecuencies.

Thanks in advance.

Mladen Bruck

Jun 07, 2014, 01:38 am Last Edit: Jun 07, 2014, 01:40 am by Mladen Bruck Reason: 1

I'm trying to measure frequency, and display always return on decimal place less. It should show 26640, but show only 2664. I also tryed to increase/decrease frequency, but same error occur.

I'm using FreqCounter library.  

This is the code:

Code: [Select]
#include <FreqCounter.h>

unsigned long frq;
int cnt;
int pinLed=13;

void setup() {
  pinMode(pinLed, OUTPUT);

  Serial.begin(115200);        // connect to the serial port

  Serial.println("Frequency Counter");

void loop() {

  // wait if any serial is going on
  FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
  FreqCounter::start(100);  // 100 ms Gate Time

  while (FreqCounter::f_ready == 0)

  Serial.print("  Freq: ");
  digitalWrite(pinLed,!digitalRead(pinLed));  // blink Led


Please help !

BR !



while (FreqCounter::f_ready == 0)

is this really what you meant  ?
or is the  ;   missing

while (FreqCounter::f_ready == 0) ;

the difference is effectively a different loop

while (FreqCounter::f_ready == 0)


while (FreqCounter::f_ready == 0)  {}
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Mladen Bruck


I didn't notice missing ; since compiled without error.  But I have found yet another post with similar problem. I'll try your both proposal.   Thank you.


There is a workoround for use with servo library?

I have not yet tried this code yet, so if it doesn't work I am sorry!  When I thought of a workaround, I was thinking external.  I found the liked below chip on adafruit that takes an I2C signal and can create PWM without using the AtMel's PWM.  As long as the communications clock is not disabled or messed up, something like this might work for you. 


Go Up