覆盆子水流量传感器如何使用?
我正在尝试将此水流传感器与覆盆子一起使用: https://www.adafruit.com/products/828 我正在使用此python代码读取脉冲: #!/usr/bin/env python import RPi.GPIO as GPIO import time, sys FLOW_SENSOR = 23 GPIO.setmode(GPIO.BCM) GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) global count count = 0 def countPulse(channel): global count count = count+1 print count GPIO.add_event_detect(FLOW_SENSOR, GPIO.RISING, callback=countPulse) while True: try: time.sleep(1) except KeyboardInterrupt: print '\ncaught keyboard interrupt!, bye' GPIO.cleanup() …