I'm working on a simple script that detects a voltage drop on a circuit. Specifically, when a doorbell is pressed. I've wired the doorbell up to GPIO pins.
The below Python script works, however, it only outputs a result the first time a voltage drop is detected. If I press the doorbell a second time, It doesn't output a result.
Please could someone point me in the right direction to update my script to continuously listen for additional voltage drop events, rather than just the first one? Essentially, looping it back to listen for additional events after the 100ms debounce.
#!/usr/bin/env python3 import signal import sys import os import RPi.GPIO as GPIO BUTTON_GPIO = 23 def signal_handler(sig, frame): GPIO.cleanup() sys.exit(0) def button_pressed_callback(channel): print("button pressed") if __name__ == '__main__': GPIO.setmode(GPIO.BCM) GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(BUTTON_GPIO, GPIO.FALLING,callback=button_pressed_callback, bouncetime=100) signal.signal(signal.SIGINT, signal_handler) signal.pause()