Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #LightTimer
- import time
- import RPi.GPIO as gpio
- from gpiozero import LED, PWMLED
- #gpio.setmode(gpio.BOARD)
- #gpio.setup(5, gpio.OUT)
- lights = PWMLED(3)
- h = time.localtime()[3]
- while True:
- try:
- h = time.localtime()[3]
- if h >= 18 or h <= 4 :
- #gpio.output(5, True)
- lights.pulse(10,10)
- else:
- #gpio.output(5, False)
- lights.off()
- time.sleep(20*60)
- except KeyboardInterrupt:
- #gpio.output(5, False)
- #gpio.cleanup()
- lights.off()
- raise
- #gpio.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement