门状态始终为0

问题描述 投票:0回答:1

我在 Cisco PT 中做了一个项目。我将门连接到 SBC。我希望门打开时 LCD 显示“Open”,门关闭时 LCD 显示“Closed”。

但我不知道为什么如果我打开或关上门,门状态总是0。

我试过这个:

#pin d1 门 #pin d0 LCD

if digitalRead(1) == HIGH: #1 is door pin
    customWrite(0, "OPEN")
else:
    customWrite(0, "Close")

完整代码

from gpio import * 

pinMode(5, INPUT) #this is a switch and if it is turned on then it is supposed to check the door 
pinMode(0, OUTPUT) 
pinMode(1, INPUT) 

while True: 
    if digitalRead(5) == HIGH: 
        if digitalRead(1) == HIGH: 
            digitalWrite(0, "Open") 
        else: 
            digitalWrite(0, "Closed")

python iot cisco
1个回答
0
投票

你设置pinMode了吗?

    # Set pin mode for door pin
    pinMode(1, INPUT)

请提供有问题的代码的全部部分。

© www.soinside.com 2019 - 2024. All rights reserved.