def __init__(self):
''' initialize the pin for the anemometer sensor '''
self.SENSOR_PIN = 4
self.count = 0
# tell the GPIO module that we want to use the chip's pin numbering scheme
GPIO.setmode(GPIO.BCM)
# setup pin as an input with pullup
GPIO.setup(self.SENSOR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# threaded event, to detect voltage falling on anemometer
# bouncetime is in ms - edges within this time will be ignored
GPIO.add_event_detect(self.SENSOR_PIN, GPIO.FALLING, bouncetime=30)
self.starttime = time.time()
# deal with events by calling a function
GPIO.add_event_callback(self.SENSOR_PIN, self.inputEventHandler)
评论列表
文章目录