您好,我目前正在使用此功能,但我感到困惑,为什么当我按按钮时BCM 18却什么也不做
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(27,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
counter = 0
totalPulse = 0
try:
while True:
sleep(0.1)
GPIO.wait_for_edge(27, GPIO.RISING)
print("Hello 27!", counter)
totalPulse = counter
counter+=1
input_state = GPIO.input(18)
if input_state == False:
totalPulse - 1
print(totalPulse)