Created
October 14, 2015 14:10
-
-
Save waveform80/d573f517052e206ad85d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from gpiozero import LED, MotionSensor, LightSensor | |
from signal import pause | |
pir = MotionSensor(21) | |
ldr = LightSensor(26) | |
light = LED(25) | |
def daytime(): | |
pir.when_motion = None | |
pir.when_no_motion = None | |
light.off() | |
def nighttime(): | |
pir.when_motion = light.on | |
pir.when_no_motion = light.off | |
ldr.when_light = daytime | |
ldr.when_dark = nighttime | |
pause() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment