Skip to content

Instantly share code, notes, and snippets.

@waveform80
Created October 14, 2015 14:10
Show Gist options
  • Save waveform80/d573f517052e206ad85d to your computer and use it in GitHub Desktop.
Save waveform80/d573f517052e206ad85d to your computer and use it in GitHub Desktop.
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