I am trying to teach myself Python and am having some questions. I understand the general idea, I just need some help fine tuning it.
Thank you
#imports
import RPi.GPIO as GPIO
import datetime
import time
#Relay 1 board number
R1 = 26
GPIO.setmode(GPIO.BCM)
GPIO.setup(R1, GPIO.OUT)
h_d = user_input
#start prompts
print("Light schedule")
time.sleep(2)
print("Input hours/day:") #Need command to request user input
print("Hours of light per day =", h_d) #Missing something
#loop
try:
while True:
now = datetime.datetime.now().time()
GPIO.output(R1,GPIO.LOW)
if now.hour == 7: #Daily start time
GPIO.output(R1, GPIO.HIGH)
print("Lights ON @") #Need it to print only once per occurrence
print(time.strftime("%-I:%M %p")) #Something missing
elif start_time + user_input
GPIO.output(R1, GPIO.LOW)
print("Lights OFF @") #Need it to print only once per occurrence
print(time.strftime("%-I:%M %p")) #Something missing
finally:
GPIO.cleanup()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…