我是 python 新手,对 python 缩进完全陌生。每当我尝试运行以下代码时都会出现语法错误,这是什么问题?已经谢谢了。
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
def RC_Analog (Pin):
counter = 0
# Discharge capacitor
GPIO.setup(Pin, GPIO.OUT)
GPIO.output(Pin, GPIO.LOW)
time.sleep(0.1)
GPIO.setup(Pin, GPIO.IN)
# Count loops until voltage across capacitor reads high on GPIO
while(GPIO.input(Pin)==GPIO.LOW):
counter =counter+1
return counter
# Set up header pin 11 as an input
triggerPin = 25;
echoPin = 8;
GPIO.setmode(GPIO.BCM)
GPIO.setup(triggerPin, GPIO.OUT)
GPIO.setup(echoPin, GPIO.IN)
while True:
GPIO.output(triggerPin, False)
time.sleep(0.000002)
GPIO.output(triggerPin, True)
time.sleep(0.00001)
GPIO.output(triggerPin, False)
print RC_Analog(echoPin)/58
time.sleep (0.25)