在08:30 WebIOPi raspberry pi 3开启灯

时间:2016-11-11 16:01:23

标签: raspberry-pi3 webiopi

用于设置hour_on | hour_off,配置中有这些命令:

HOUR_ON  = 8  # Turn Light ON at 08:00
HOUR_OFF = 18 # Turn Light OFF at 18:00

没关系,但如果我在08:30设置HOUR_ON

1 个答案:

答案 0 :(得分:1)

您必须修改示例程序以添加分钟功能。 有关Python日期操作的详细信息,请参阅this page

This page说明如何修改minutes功能以添加def loop(): # Get the current time now = datetime.time(datetime.datetime.now().hour, datetime.datetime.now().minute) # Automatically switch on LED if ((now.hour == HOUR_ON.hour) and (now.minute == HOUR_ON.minute) and (now.second == 0)): if (GPIO.digitalRead(LIGHT) == GPIO.LOW): GPIO.digitalWrite(LIGHT, GPIO.HIGH) # Automatically switch off LED if ((now.hour == HOUR_OFF.hour) and (now.minute == HOUR_OFF.minute) and (now.second == 0)): if (GPIO.digitalRead(LIGHT) == GPIO.HIGH): GPIO.digitalWrite(LIGHT, GPIO.LOW) # Repeat every 1 second webiopi.sleep(1) 功能,

Some "Quotes" are needed