Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
PCBX
Published

Frequency Meter Based on Arduino UNO

Introducing our Arduino UNO-based Frequency Meter: a compact, accurate tool for measuring signals

BeginnerFull instructions provided206
Frequency Meter Based on Arduino UNO

Things used in this project

Story

Read more

Schematics

arduino_uno-based_frequency_meter_v1yjfJL4Ld.png

Code

Arduino UNO-based Frequency Meter

Arduino
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
const int signalPin = A0;

unsigned long pulseStartTime = 0;
unsigned long pulseCount = 0;
float frequency = 0.0;

void setup() {
  pinMode(signalPin, INPUT);
  
  lcd.begin(16, 2);
  lcd.print("Frequency(Hz):");
}

void loop() {
  if (digitalRead(signalPin) == HIGH) {
    if (pulseStartTime == 0) {
      pulseStartTime = millis();
    }
  } else {
    if (pulseStartTime != 0) {
      pulseCount++;
      unsigned long pulseDuration = millis() - pulseStartTime;
      frequency = 1000.0 / (pulseDuration / (pulseCount - 1));
      pulseStartTime = 0;
    }
  }

  lcd.setCursor(9, 1);
  lcd.print(frequency, 4); 
  
  delay(100);
}

Credits

PCBX
33 projects • 10 followers
Customer Success: Your one-stop solution for PCB and PCBA services, plus component sourcing. Enjoy FREE online simulation and EDA.
Contact

Comments

Please log in or sign up to comment.