ambhatt
Published © GPL3+

Frequency and Duty Cycle Measurement Using Arduino

Arduino is used to measure frequency and duty cycle of pulses and display them on LCD.

IntermediateFull instructions provided76,522
Frequency and Duty Cycle Measurement Using Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Alphanumeric LCD, 20 x 4
Alphanumeric LCD, 20 x 4
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Breadboard, 270 Pin
Breadboard, 270 Pin

Story

Read more

Schematics

frequency and duty cycle measurement using Arduino circuit

the circuit measures frequency and duty cycle of pulse using Arduino

Code

program to measure frequency and duty cycle and display it on LCD

C/C++
measure frequency and duty cycle and display it on LCD
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define pulse_ip 7
int ontime,offtime,duty;
float freq,period;
   
void setup()
{
  pinMode(pulse_ip,INPUT);
  lcd.begin(16, 4);
  lcd.clear();
  lcd.print("Freq:");
  lcd.setCursor(0,1);
  lcd.print("Ton:");
  lcd.setCursor(0,2);
  lcd.print("Toff:");  
  lcd.setCursor(0,3);
  lcd.print("Duty:");  
}
void loop()
{
   ontime = pulseIn(pulse_ip,HIGH);
   offtime = pulseIn(pulse_ip,LOW);
   period = ontime+offtime;
   freq = 1000000.0/period;
   duty = (ontime/period)*100; 
   lcd.setCursor(4,1);
   lcd.print(ontime);
   lcd.print("us");
   lcd.setCursor(5,2);
   lcd.print(offtime); 
   lcd.print("us");   
   lcd.setCursor(5,0); 
   lcd.print(freq);
   lcd.print("Hz");
   lcd.setCursor(6,3);
   lcd.print(duty); 
   lcd.print('%'); 
   delay(1000);
}

Credits

ambhatt

ambhatt

5 projects • 39 followers

Comments