Arduino Frequency Counter - Simple Projects

This post shows how to build a frequency counter device using Arduino UNO board where signal frequency value is displayed on 1602 LCD screen. With this counter we can measure frequency of PWM signals with peak voltage of 5V.

Related Project: 220/380V AC Frequency Meter with Arduino

Hardware Required: This is a list of all components required to build this project.

  • Arduino UNO board   —-> Atmega328P datasheet
  • 16×2 LCD screen
  • 330 ohm resistor
  • 10k ohm variable resistor or potentiometer
  • Breadboard
  • Jumper wires

Arduino frequency counter circuit with LCD

Arduino frequency counter circuit: Project circuit diagram is shown below.

The 16×2 LCD screen (2 rows and 16 columns) is used to display the values of frequency and period of the input voltage where: RS —> Arduino digital pin 2 E   —> Arduino digital pin 3 D4 —> Arduino digital pin 4 D5 —> Arduino digital pin 6 D6 —> Arduino digital pin 7 D7 —> Arduino digital pin 8 VSS, RW, D0, D1, D2, D3 and K are connected to Arduino GND, VEE to the 10k ohm variable resistor (or potentiometer) output, VDD to Arduino 5V and A to Arduino 5V through 330 ohm resistor.

VEE pin is used to control the contrast of the LCD. A (anode) and K (cathode) are the back light LED pins.

Arduino frequency counter circuit with LCD

The PWM signal has two pins, let’s say positive (+) and negative (-), they are connected to the circuit as shown above. The positive terminal is connected to Arduino digital pin 5 and the negative terminal is connected to Arduino GND pin.

Arduino frequency counter code The following Arduino code requires a library which helps doing this project easily. This library is named FreqCount, it can be installed online through Arduino library manger (Manage Libraries…) or manually by downloading and installing its zip file. Download link is below: Arduino FreqCount library    —-> direct link

The FreqCount library uses Timer/Counter1 module to count number of pulses during fixed time, Timer/Counter2 module is used for this fixed time.

Full Arduino code:

/************************************************************************* * * Arduino frequency counter. * This is a free software with NO WARRANTY. * https://simple-circuit.com/ * ************************************************************************/ #include <FreqCount.h> #include <LiquidCrystal.h> // include Arduino LCD library // LCD module connections (RS, E, D4, D5, D6, D7) LiquidCrystal lcd(2, 3, 4, 6, 7, 8); void setup(void) { // set up the LCD's number of columns and rows lcd.begin(16, 2); lcd.print("FREQUENCY:"); // initialize freqCount library with time basis of 1000ms (1 second) // Arduino counts number of pulses during period of 1 second FreqCount.begin(1000); } // main loop void loop() { if (FreqCount.available()) { unsigned long count = FreqCount.read(); lcd.setCursor(0, 1); lcd.print(count); // print frequency value in Hz lcd.print(" Hz "); } } // end of code.
1234567891011121314151617181920212223242526272829303132333435363738/************************************************************************* * * Arduino frequency counter. * This is a free software with NO WARRANTY. * https://simple-circuit.com/ * ************************************************************************/ #include <FreqCount.h>#include <LiquidCrystal.h> // include Arduino LCD library // LCD module connections (RS, E, D4, D5, D6, D7)LiquidCrystal lcd(2,3,4,6,7,8); voidsetup(void){// set up the LCD's number of columns and rowslcd.begin(16,2);lcd.print("FREQUENCY:");// initialize freqCount library with time basis of 1000ms (1 second)// Arduino counts number of pulses during period of 1 secondFreqCount.begin(1000); } // main loopvoidloop(){if(FreqCount.available()){unsignedlongcount=FreqCount.read(); lcd.setCursor(0,1);lcd.print(count);// print frequency value in Hzlcd.print(" Hz ");} } // end of code.

The video below shows a protoboard circuit of the project:

Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

Type your email…

Subscribe

Tag » Arduino Hz Counter