I have been trying to read the number of pulse inputs from an external device. The pulse generated is from the arduino uno, and the pin I am using has a frequency of 450hz with 5% duty cycle.
Every time the pulse count shows aroung 2300-3000 per second.
I also have check the frequency of the arduino pin using an Oscilloscope
model- raspberry pi zero W
below is my python code for counting pulse using interrupts to count the pulse within a time interval of 1 sec.
import RPi.GPIO as GPIO import time, sys pulse_gpio=26 GPIO.setmode(GPIO.BCM) GPIO.setup(pulse_gpio,GPIO.IN, pull_up_down=GPIO.PUD_UP) global count count=0 def counting(channel): global count if start_counter==1: count=count+1 GPIO.add_event_detect(pulse_gpio, GPIO.FALLING, callback=counting) while True: try: start_counter=1 time.sleep(1) start_counter=0 flow=count print(flow) count=0 #time.sleep(0.5) except keyboardInterrupt: print("keyboard") GPIO.cleanup() sys.exit()