我是新的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)
你能告訴我們實際的錯誤信息嗎? – Volatility 2013-04-20 13:59:21
SyntaxError會告訴你問題出在哪一行。 – Aya 2013-04-20 13:59:42
def?RC_Analog(Pin)它突出了標記區域 – mozcelikors 2013-04-20 14:01:33