-
-
Save RedTahr/5d3c31c7b8f45cb0215ea64ad161342b 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
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