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 datetime import datetime | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(17,GPIO.OUT) | |
def lights_on(): | |
""" Turn the lights on. """ | |
GPIO.output(17,GPIO.LOW) | |
def lights_off(): | |
""" Turn the lights off. """ | |
GPIO.output(17,GPIO.HIGH) | |
if __name__ == "__main__": | |
hour = datetime.now().hour | |
if hour >= 9 and hour < 21: | |
lights_on() | |
else: | |
lights_off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment