I have been working on a raspberry pi custom built Dr. Who doorbell for some time. I would like to use a raspberry pi zero that i will install behind the front doorbell to activate my program. I have successfully run the script that will communicate with the correct pin and run my program which selects random mp3's from the show and plays them via my other RPI. However for the life of me i cannot ascertain why the button I have wired cannot be used as reliable input. What i mean is the program starts and loops continuously. I am trying to have the script run and await input so when i press what will be the front doorbell (my button) then the audio will play. Ive done this successfully before. Just not using remote GPIO. It was wired and i used RPi.GPIO. My script is as follows.
Code: Select all
from gpiozero import * from gpiozero.pins.pigpio import PiGPIOFactory import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP) factory = PiGPIOFactory(host='192.168.1.13') led = LED(18, pin_factory=factory) while True: input_state = GPIO.input(3) if input_state == False: led.on() time.sleep(1) led.off()