Adafruit_Learning_System_Gu.../CircuitPython_Sip_and_Puff/code.py
2020-02-11 09:49:33 -08:00

23 lines
536 B
Python

import puff_detector
detector = puff_detector.PuffDetector()
@detector.on_sip
def on_sip(strength, duration):
if strength == puff_detector.STRONG:
print("GOT STRONG SIP")
if strength == puff_detector.SOFT:
print("GOT SOFT SIP")
print("%.2f long" % duration)
@detector.on_puff
def on_puff(strength, duration):
if strength == puff_detector.STRONG:
print("GOT STRONG PUFF")
if strength == puff_detector.SOFT:
print("GOT SOFT PUFF")
print("%.2f long" % duration)
detector.run()