Devices & Components
Arduino Uno Rev3
Alphanumeric LCD, 20 x 4
Hardware & Tools
Breadboard, 270 Pin
Software & Tools
Arduino IDE
Project description
Code
program to measure frequency and duty cycle and display it on LCD
c_cpp
measure frequency and duty cycle and display it on LCD
1#include <LiquidCrystal.h> 2 3LiquidCrystal lcd(8, 9, 10, 11, 12, 13); 4#define pulse_ip 7 5int ontime,offtime,duty; 6float freq,period; 7 8void setup() 9{ 10 pinMode(pulse_ip,INPUT); 11 lcd.begin(16, 4); 12 lcd.clear(); 13 lcd.print("Freq:"); 14 lcd.setCursor(0,1); 15 lcd.print("Ton:"); 16 lcd.setCursor(0,2); 17 lcd.print("Toff:"); 18 lcd.setCursor(0,3); 19 lcd.print("Duty:"); 20} 21void loop() 22{ 23 ontime = pulseIn(pulse_ip,HIGH); 24 offtime = pulseIn(pulse_ip,LOW); 25 period = ontime+offtime; 26 freq = 1000000.0/period; 27 duty = (ontime/period)*100; 28 lcd.setCursor(4,1); 29 lcd.print(ontime); 30 lcd.print("us"); 31 lcd.setCursor(5,2); 32 lcd.print(offtime); 33 lcd.print("us"); 34 lcd.setCursor(5,0); 35 lcd.print(freq); 36 lcd.print("Hz"); 37 lcd.setCursor(6,3); 38 lcd.print(duty); 39 lcd.print('%'); 40 delay(1000); 41}
program to measure frequency and duty cycle and display it on LCD
c_cpp
measure frequency and duty cycle and display it on LCD
1#include <LiquidCrystal.h> 2 3LiquidCrystal lcd(8, 9, 10, 11, 12, 13); 4#define pulse_ip 7 5int ontime,offtime,duty; 6float freq,period; 7 8void setup() 9{ 10 pinMode(pulse_ip,INPUT); 11 lcd.begin(16, 4); 12 lcd.clear(); 13 lcd.print("Freq:"); 14 lcd.setCursor(0,1); 15 lcd.print("Ton:"); 16 lcd.setCursor(0,2); 17 lcd.print("Toff:"); 18 lcd.setCursor(0,3); 19 lcd.print("Duty:"); 20} 21void loop() 22{ 23 ontime = pulseIn(pulse_ip,HIGH); 24 offtime = pulseIn(pulse_ip,LOW); 25 period = ontime+offtime; 26 freq = 1000000.0/period; 27 duty = (ontime/period)*100; 28 lcd.setCursor(4,1); 29 lcd.print(ontime); 30 lcd.print("us"); 31 lcd.setCursor(5,2); 32 lcd.print(offtime); 33 lcd.print("us"); 34 lcd.setCursor(5,0); 35 lcd.print(freq); 36 lcd.print("Hz"); 37 lcd.setCursor(6,3); 38 lcd.print(duty); 39 lcd.print('%'); 40 delay(1000); 41}
Downloadable files
frequency and duty cycle measurement using Arduino circuit
the circuit measures frequency and duty cycle of pulse using Arduino
frequency and duty cycle measurement using Arduino circuit

Comments
Only logged in users can leave comments