Build it step by step
0 of 6 doneBuild the input buffer
Place the 74HC14. Power pin 14 from 5V, pin 7 to GND, with 100 nF between them.
Chain two inverters
Join output 1Y (pin 2) to input 2A (pin 3). Take output 2Y (pin 4) to D5.
Add the input resistor
Put 1 kΩ between your signal and pin 1. Connect the signal ground to Uno GND.
Wire the LCD
SDA to A4, SCL to A5, VCC to 5V, GND to GND.
Upload
Install the LCD library and upload.
Test it
Measure a 555 astable output, or a function generator at 1 kHz.
How do you build a frequency counter?
Count pulses on the Timer1 input for exactly one second to measure frequency up to about 5 MHz, shown on an LCD. You need Arduino Uno R3, 74HC14 hex Schmitt-trigger inverter, Resistor 1 kΩ, Ceramic Capacitor 100 nF, 16x2 LCD with I2C backpack (PCF8574), Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- Integrated CircuitsBuy
- PassivesBuyResistor 1 kΩ × 1
- PassivesBuy
- DisplaysBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Signal in | 1 kΩ to 74HC14 pin 1 (input 1A) | Series resistor protects the input |
| 74HC14 pin 2 (output 1Y) | 74HC14 pin 3 (input 2A) | Two inverters give a clean, non-inverted square wave |
| 74HC14 pin 4 (output 2Y) | Uno D5 (T1, Timer1 clock input) | Pulses to count |
| 74HC14 pin 14 / pin 7 | Uno 5V / GND, with 100 nF across them | Power and decoupling |
| Signal ground | Uno GND | Shared ground, essential |
| LCD SDA / SCL / VCC / GND | Uno A4 / A5 / 5V / GND | Display |
Code
Arduino IDE, board "Arduino Uno" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "LiquidCrystal I2C" by Frank de Brabander. Only the 5 V signals of 0 to 5 V are allowed. The Uno's ceramic resonator is about 0.5 % accurate, so readings are good to about that.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
volatile unsigned long overflows;
ISR(TIMER1_OVF_vect) { overflows++; } // counts every 65536 pulses
void setup() {
pinMode(5, INPUT); // D5 is the Timer1 clock input on the Uno
lcd.init(); lcd.backlight();
lcd.print("Frequency");
}
void loop() {
noInterrupts();
TCCR1A = 0; TCCR1B = 0; TCNT1 = 0; overflows = 0;
TIMSK1 = _BV(TOIE1); // interrupt on overflow
interrupts();
TCCR1B = _BV(CS12) | _BV(CS11) | _BV(CS10); // external clock, rising edge: counting starts
delay(1000); // the one-second gate
TCCR1B = 0; // stop counting
unsigned long hz = (overflows << 16) + TCNT1;
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
if (hz >= 1000000UL) { lcd.print(hz / 1000000.0, 3); lcd.print(" MHz"); }
else if (hz >= 1000) { lcd.print(hz / 1000.0, 2); lcd.print(" kHz"); }
else { lcd.print(hz); lcd.print(" Hz"); }
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Function generator at 1 kHz | Reads 1.00 kHz (within about 0.5 %) |
| 555 astable at about 1 kHz | Reads close to the calculated frequency |
| Input disconnected | Reads 0 Hz, or a little mains hum if the wire is floating |
| Input at 4 MHz | Reads about 4.000 MHz |
If it does not work
Readings jump about with nothing connected
A floating input picks up noise. Connect the signal ground and use a short lead.
Reads half the frequency or double
Check you chained two inverters, not one, and that the generator output is a square wave of 3 V or more.
Always 0 Hz
Check the signal goes to D5, not D4, and the 74HC14 has power on pins 14 and 7.
Never exceed 5 V
For higher voltages use a divider first, or you can damage the chip.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the frequency counter?
Arduino Uno R3, 74HC14 hex Schmitt-trigger inverter, Resistor 1 kΩ, Ceramic Capacitor 100 nF, 16x2 LCD with I2C backpack (PCF8574), Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the frequency counter take to build?
About 90 minutes for a beginner maker, in 6 steps.
How do I know the frequency counter works?
Function generator at 1 kHz: Reads 1.00 kHz (within about 0.5 %). 555 astable at about 1 kHz: Reads close to the calculated frequency. Input disconnected: Reads 0 Hz, or a little mains hum if the wire is floating.
Readings jump about with nothing connected: what should I check?
A floating input picks up noise. Connect the signal ground and use a short lead.
Reads half the frequency or double: what should I check?
Check you chained two inverters, not one, and that the generator output is a square wave of 3 V or more.
Always 0 Hz: what should I check?
Check the signal goes to D5, not D4, and the 74HC14 has power on pins 14 and 7.
Never exceed 5 V: what should I check?
For higher voltages use a divider first, or you can damage the chip.
