Frequency Counter using Arduino

Almost every electronic hobbyist must have faced a scenario where he or she must measure the frequency of signal generated by a clock or a counter or a timer.  We can use oscilloscope to do the job, but not all of us can afford an oscilloscope. We can buy equipment for measuring the frequency but all these devices are costly and are not for everyone. With that in mind we are going to design a simple yet efficient Frequency Counter using Arduino Uno and Schmitt trigger gate.

This Frequency Counter is cost effective and can be easily made, we are going to use ARDUINO UNO for the measuring the frequency of signal, UNO is the heart of project here.

To test the Frequency Meter, we are going to make a dummy signal generator. This dummy signal generator will be made by using a 555 timer chip. The timer circuit generates a square wave which will be provided to UNO for testing.Frequency Counter using Arduino

Required Components:

  • 555 timer IC and 74LS14 Schmitt trigger gate or NOT gate.
  • 1K Ω resistor(2 pieces), 100Ω resistor
  • 100nF capacitor (2 pieces), 1000µF capacitor
  • 16*2 LCD,
  • 47KΩ pot,
  • Breadboard and some connectors.

Circuit Explanation:

The circuit diagram of the Frequency Meter using Arduino is shown in below figure. Circuit is simple, a LCD is interfaced with Arduino to display the measured frequency of signal. ‘Wave Input’ is going to Signal Generator Circuit, from which we are feeding signal to Arduino. A Schmitt trigger gate (IC 74LS14) is used to ensure that only rectangular wave is fed to Arduino. For filtering the noise we have added couple of capacitors across power. This Frequency Meter can measure frequencies up to 1 MHz.Frequency Counter using Arduino

Signal generator circuit and Schmitt trigger have been explained below.

Signal Generator using 555 Timer IC:

First of all we will talk about 555 IC based square wave generator, or should I say 555 Astable Multivibrator.  This circuit is necessary because, with the Frequency Meter in place we must have a signal whose frequency is known to us. Without that signal we will never be able to tell the working of Frequency Meter. If we have a square have of known frequency we can use that signal to test the Arduino Uno Frequency Meter and we can tweak it for adjustments for accuracy, in case of any deviations. The picture of Signal Generator using 555 Timer IC is given below:

Typical circuit of 555 in Astable mode is given below, from which we have derived the above given Signal Generator Circuit.

The output signal frequency depends on RA, RB resistors and capacitor C. The equation is given as,

Frequency (F) = 1/ (Time period) = 1.44/ ((RA+RB*2)*C).

Here RA and RB are resistance values and C is capacitance value. By putting the resistance and capacitance values in above equation we get the frequency of output square wave.

One can see that RB of above diagram is replaced by a pot in the Signal Generator Circuit; this is done so that we can get variable frequency square wave at the output for better testing. For simplicity, one can replace the pot with a simple resistor.

Schmitt Trigger Gate:

We know that all the testing signals are not square or rectangular waves. We have triangular waves, tooth waves, sine waves and so on. With the UNO being able to detect only the square or rectangular waves, we need a device which could alter any signals to rectangular waves, thus we use Schmitt Trigger Gate. Schmitt trigger gate is a digital logic gate, designed for arithmetic and logical operations.

This gate provides OUTPUT based on INPUT voltage level. A Schmitt Trigger has a THERSHOLD voltage level, when the INPUT signal applied to the gate has a voltage level higher than the THRESHOLD of the logic gate, OUTPUT goes HIGH. If the INPUT voltage signal level is lower than THRESHOLD, the OUTPUT of gate will be LOW. We don’t usually get Schmitt trigger separately, we always have a NOT gate following the Schmitt trigger. Schmitt Trigger working is explained here: Schmitt Trigger Gate

We are going to use 74LS14 chip, this chip has 6 Schmitt Trigger gates in it. These SIX gates are connected internally as shown in below figure.

The Truth Table of Inverted Schmitt Trigger gate is show in below figure, with this we have to program the UNO for inverting the positive and negative time periods at its terminals.

Now we will feed any type of signal to ST gate, we will have rectangular wave of inverted time periods at the output, we will feed this signal to UNO.

Arduino Frequency Counter Code Explanation:

Code for this frequency measurement using arduino is quite simple and easily understandable. Here we are explaining the pulseIn function which is mainly responsible measuring the frequency. The Uno has a special function pulseInwhich enables us to determine the positive state duration or negative state duration of a particular rectangular wave:

Htime = pulseIn(8,HIGH);
Ltime = pulseIn(8, LOW);

The given function measures the time for which High or Low level is present at PIN8 of Uno. So in a single cycle of wave, we will have the duration for the positive and negative levels in Micro seconds. The pulseIn function measures the time in micro seconds. In a given signal, we have high time = 10mS and low time = 30ms (with frequency 25 HZ). So 30000 will be stored in Ltime integer and 10000 in Htime. When we add them together we will have the Cycle Duration, and by inverting it we will have the Frequency.

Complete code and video for this Frequency Meter using Arduino are given below.


#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

int Htime;              //integer for storing high time
int Ltime;                //integer for storing low time
float Ttime;            // integer for storing total time of a cycle
float frequency;        //storing frequency

void setup()
lcd.begin(16, 2);
void loop()
lcd.print(“Frequency of signal”);

Htime=pulseIn(8,HIGH);      //read high time
Ltime=pulseIn(8,LOW);        //read low time

Ttime = Htime+Ltime;

frequency=1000000/Ttime;    //getting frequency with Ttime is in Micro seconds
lcd.print(” Hz”);


Read More:  Frequency Counter using Arduino

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top