通过查看其他pir传感器脚本来控制一组色调条带,我成功地将这一点组合在一起。这可能是更好的方法,但这是我的地方。在
问题是这些脚本会覆盖我从“说我的手机”应用程序所做的任何事情。 如果我打开手机上的灯,而传感器旁边没有任何移动,它会在一两秒钟后熄灭指示灯。我想避免这种情况,我希望这个脚本能够被其他地方的控件溢出。有人能帮我解决这个问题吗?在
编辑;编辑时间。睡觉使用(60*30)是因为我希望在pir传感器前面发生移动后,灯保持亮起30分钟。也许有更好的解决办法?在
正在执行的两个脚本只是告诉hue bridge打开/关闭灯光的两个脚本。 让我知道如果有任何原因需要这些,我会张贴他们。在
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(15, GPIO.IN)
while True:
i=GPIO.input(15)
caseCommand = getinput()
if (i==0) and (caseCommand == 0):
print "No movement detected - Turning lights off",i
exec(open("./LightsOff.py").read(), globals())
time.sleep(1)
if (i==1) or(caseCommand == 1):
print "Movement detected - Turning lights on",i
exec(open("./LightsOn.py").read(), globals())
time.sleep(60 * 30)
编辑:代码现在如上所示。但不知道怎么写这个函数。 显然,上面给出了一个关于函数的错误。。在
你的程序正在做它应该做的!!!在
如果有运动(我=GPIO.input.输入(15) )它会打开灯,如果没有移动,它会关闭灯!!!在
你必须在你的if语句中加上一些额外的情况!!!在
例如:
下面是一个更详细的例子:
^{pr2}$相关问题 更多 >
编程相关推荐