我有一个带有 Siri 代理的 Raspberry Pi,它控制着我的车库门,车库门只有一个打开和关闭命令。为了检查车库门是否打开,我买了一个磁铁开关,并制作了一个无视点按钮。我已经试过了
doorstate = `gpio read 5`.chomp #gives value 1 or 0, 1 is opened, 0 is closed
print doorstate
if doorstate == "1"
print "The garage door is already opened.\n"
elsif doorstate == "0"
print "OK, I'll open it for you!\n"
else
print "Error, please open it manually.\n"
end
有人可以告诉我如何检查返回的值或字符串doorstate = 'gpio read 5'
是否等于字符串?