Skip to content

Instantly share code, notes, and snippets.

@iHexile
Created March 26, 2020 21:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iHexile/289310fe9a5150952ec448608303ab50 to your computer and use it in GitHub Desktop.
Save iHexile/289310fe9a5150952ec448608303ab50 to your computer and use it in GitHub Desktop.
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