Created
May 5, 2016 12:26
-
-
Save Sirfrummel/8166db2e69d64168d37974bfdc5632c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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