#initialize import time import RPI.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(23, GPIO.OUT) # Stepo GPIO.setup(24, GPIO.OUT) # Direction input_value = GPIO.input(11) # GPIO.HIGH == 1 and GPIO.LOW == 0 filterValue = 0 # 0 is initialized value #filterWheelIndex = [“startlocation”,“wavelength1”,”wavelenght2”,”wavelength3”] filterWheelIndex = [sloc,wlen1,wlen2,wlen3] #print 'Filter Value currently at:', filterWheelIndex(filterValue) #print filterWheelIndex(filterValue) startLocation() def startLocation(): if input_value == 1: #print 'Intial location found' print 1 filterValue = 1 # Filter #1 location. print 'Filter Value currently at:' + filterWheelIndex(filterValue) return 1; elif input_value == 0: print 'Continue Turning' else: print 'Should never hit else' # elif can be replaced with else. assuming no mistakes def incrementLocation(): if filterValue == 2: print 'Filter Value currently at:' + filterWheelIndex(filterValue) return 0 else: clockwiseRotation(filterValue): filterValue = filterValue +1; # can change to include wavelengths based on filterValue number value print 'Filter Value currently at:' + filterWheelIndex(filterValue) def clockwiseRotation(number): GPIO.output(24, GPIO.LOW) i = 0 for 425 >= i: if 425 > i: GPIO.output(23, GPIO.HIGH) time.sleep(2) GPIO.output(23,GPIO.LOW) time.sleep(2) print 'step number #' + i i = i + 1 else: print 'step number #' + i return 1
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