Frequency counter using Arduino (up to 40KHz).

Many guys here were asking for a frequency counter and at last I got enough time to make one.  This frequency counter using arduino is based on the UNO version and can count up to 40KHz. A 16×2 LCD display is used for displaying the frequency count. The circuit has minimum external components and directly counts the frequency. Any way the amplitude of the input frequency must not be greater than 5V. If you want to measure signals over than 5V, additional limiting circuits have to be added and i will show it some other time. Now just do it with 5V signals.

The frequency to be counted is connected to digital pin 12 of the Arduino. pulseIn() function is used here for counting the frequency connected to pin 12. pulseIn() function counts the number of pulses (HIGH or LOW) coming to a particular pin of the Arduino. The general syntax of this function is pulseIn(pin, value, time) where the pin is the name of the pin, the value is either HIGH or LOW and time is the time for which the function to wait for a pulse. The function returns zero if there is no valid pulse within the specified time. The pulseIn() function can count pulses with a time period ranging from 10 μS to 3 minutes. A circuit diagram of the frequency counter using Arduino is given below.

frequency counter using arduino

Potentimeter R1 is used to adjust the contrast of the LCD screen. Resistor R2 limits the current through the back light LED.

In the program, high time and low time of the input signal is measured using separate pulseIn() functions. Then the high and low times are added together to get the total time period of the signal. Frequency is just 1/time period in seconds. The pulseIn() function returns the time period in microseconds. Total timeperiod in microseconds first divided by 1000. Then 1000 is divided by the result to get the frequency in hertz. The program of the frequency counter using arduino is shown below.


#include <LiquidCrystal.h>
int input=12;

int high_time;
int low_time;
float time_period;
float frequency;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup()
lcd.begin(16, 2);
void loop()
lcd.print("Frequency Meter");


lcd.print(" Hz");

The circuit can be powered through the 9V external power jack of the Arduino. 5V DC required at some parts of the circuit can be tapped from the built-in 5V regulator of the Arduino itself. This is actually a simple counter circuit using Arduino. We can modify this circuit for other applications like tachometer, intrusion counter, etc.


  1. nandhini

    input – speed of two stepper motor
    output-digital frequency pulses which has to be further given to a driver ckt

  2. nandhini

    hi please help me for the coding

    input should be speed of the two stepper motor that has to be converted into corresponding digital frequency pulses using arduino.
    the output frequency pulse has been further given to a driver.

  3. Hello,
    I am doing project of remote monitoring and control of a generator. I am facing some difficulty in some part of the program. Could you please guide me? i can provide you my code and circuit simulation .

    thank you

  4. absinthe

    This is good but what about circuitry to limit the peak voltage of the input frequency and also to deal with a floating input – e.g. swinging between, say, -10v and +10v. My inclination is to use an op-amp buffer with a 3v9 zener between the output and ground (plus a load resistor, of course). It could also be used to shape sine and other non-sq waves into square waves.

    What it the lower limit at which the counter can act?

  5. i’m trying to measure audio frequency. is this coding able to do so?

  6. Whether can I apply the sine signal to the input pin

  7. hello sir
    if I change the frequency of the input signal simultaneously whether it is showing the exact output frequency as same as input.

    send me the screenshots of this program simulation in proteus . I am not getting the output

    • Whether can I apply the sine signal to the input pin

    • @champasit – Please wire up the circuit and use code we have given. We have tested this in our lab!

      • jojo what input you r applying to the aurdino

        pulse input? ?

  8. Debashish Mohapatra

    Could you please tell what software you are using for drawing the circuits.