I use fork light barrier sensor TCXT2103, 20 slots disk and ESP32 to measure the speed of the motor. When I run my code, I get a huge number of counts for 1 revolution (about 90) . I test tested the sensor with Arduino and got the right count (20)
could you tell me how to solve this problem please?
Thanks in advance
Code: Select all
from machine import Pin
class EncoderCounter:
def __init__(self,pin_number):
self.pulse_count = 0
self.LightB1 = Pin(pin_number,Pin.IN)
self.LightB1.irq(trigger=Pin.IRQ_RISING, handler=self.M1)
def M1(self,Pin):
self.pulse_count += 1
print(self.pulse_count)