Skip to content

Instantly share code, notes, and snippets.

@Sirfrummel
Created May 5, 2016 12:26
Show Gist options
  • Save Sirfrummel/8166db2e69d64168d37974bfdc5632c1 to your computer and use it in GitHub Desktop.
Save Sirfrummel/8166db2e69d64168d37974bfdc5632c1 to your computer and use it in GitHub Desktop.
import time
import RPi.GPIO as io
io.setmode(io.BCM)
door_pin = 12
light_pin = 16
printed = 0
loop = 1
io.setup(door_pin, io.IN, pull_up_down=io.PUD_UP) # activate input with PullUp
io.setup(light_pin,io.OUT)
io.output(light_pin, io.LOW)
while loop:
if io.input(door_pin):
print("...open...")
io.output(light_pin, io.HIGH)
else:
print("CLOSED")
io.output(light_pin, io.LOW)
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment