def test_falling(): print('Falling edge test') GPIO.set_falling_event(18) time.sleep(5) if GPIO.event_detected(18): print('Event detected') else: print('Event not detected')
def __init__(self, gpio_id, callback = None, callback_info = None): self.gpio_id = gpio_id self.callback = callback self.callback_info = callback_info gpio.setmode(gpio.BOARD) gpio.setup(gpio_id, gpio.IN, pull_up_down=gpio.PUD_UP) gpio.set_rising_event(gpio_id, enable=False) gpio.set_falling_event(gpio_id)