With this code, I can close a chicken coop door. I supervise the action with a camera. But, it would be very convenient to add a limit switch to stop the motor (which runs for 10 seconds) when the door reaches the threshold.
I don't know which gpio to plug it into and most important..., if this is the right way to do it?
Any idea how can I do that ?
Thank you for your help.
Code: Select all
import RPi.GPIO as gpio import time def init(): gpio.setmode(gpio.BCM) gpio.setup(17, gpio.OUT) gpio.setup(22, gpio.OUT) def reverse(sec): init() gpio.output(17, False) gpio.output(22, True) time.sleep(sec) gpio.cleanup() print "reverse" reverse(10)