Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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