当 gpio.input(i) = true 时,我试图让“p”翻转/翻转 0 和 1
谁能告诉我这段代码有什么问题 - 它不起作用!
import RPi.GPIO as gpio
import time as time
gpio.setmode(gpio.BOARD)
i = 15
o = 11
t = 0.3
p = 0
gpio.setup(i, gpio.IN)
gpio.setup(o, gpio.OUT)
gpio.output(o, True)
while True:
if gpio.input(i) and p == 0:
print("P = 1")
p = 1
time.sleep(2)
else:
if (gpio.input(i)) and p == 1:
p = 0
while True:
if p == 1:
gpio.output(o, False)
time.sleep(t)
gpio.output(o, True)
time.sleep(t)