#http://www.raspberrypi.org/archives/tag/tutorial #initialize #import time #import WiringPi as Wire import RPI.GPIO as GPIO #Setup Mode and Warnings GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) #GPIO Output Pin Setup and initial values GPIO.setup(23, GPIO.OUT) # Step GPIO.setup(23, GPIO.OUT, initial=GPIO.LOW) #Setting Intial Step not to start until after goes High. GPIO.setup(24, GPIO.OUT) # Direction - GPIO.setup(24, GPIO.OUT, initial=GPIO.HIGH) #Setting Intial Direction to CW #GPIO Input Pin Setup and intial values GPIO.setup(12, GPIO.IN) #Hall Effect Sensor: Stays High (1) until hits magnet goes to Low(0) GPIO.add_event_detect(12, GPIO.FALLING) #Addint detection for falling to Low (~0) #Intilize filterValue = 0 # 0 is initialized value filterWheelIndex = ['sloc','wlen1','wlen2','wlen3'] # Filter wheel values print filterWheelIndex(filterValue) startLocation() #Start Location def startLocation(): i = 0 if GPIO.event_detect(12): print ('Falling Edge has occurred after:' + i + ' revolutions!') #return to start location Code! return 1 else: print ('Count: ' + i) i = i + 1 def cleanUp(): GPIO.cleanup() return 'end'
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question