Skip to content

Instantly share code, notes, and snippets.

@iHexile
Created March 26, 2020 21:17
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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