代码import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(16,GPIO.IN)
try:
while True: # 执行一个while死循环
status=GPIO.input(16) # 检测36号引脚口的输入高低电平状态
print(status) # 实时打印此时的电平状态
if status == True: ”
print ( ' 正常 ' )
else:
print ( ' 检测到危险气体 ! ! ! ' )
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
报错traceback (most recent call last):
File "/usr/lib/python3.7/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "/home/pi/Desktop/mq23.py", line 15
else:
^
IndentationError: unindent does not match any outer indentation
|