I'm new in python and total stranger to python indentation. I get syntax error whenever I try to run the following code, what is the problem with it? Thanks already.
#!/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)
def?RC_Analog(Pin), it sounds like you have something other than a space between thedefand theRC_Analog, maybe some weird Unicode character which is similar to a space.