#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 int filterValue = 0; # 0 is initialized value filterWheelIndex = (“startlocation”,“wavelength1”,”wavelenght2”,”wavelength3”) #print “Filter Value currently at:”, filterWheelIndex(filterValue) startLocation() def startLocation(): if input_value == 1: print “Intial location found” 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(): clockwiseRotation(): filterValue = filterValue +1; # can change to include wavelengths based on filterValue number value print “Filter Value currently at:”, filterWheelIndex(filterValue) def clockwiseRotation(): GPIO.output(24, GPIO.LOW) int 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 def decrementLocation(): counterclockwiseRotation (): filterValue = filterValue - 1; # can change to include wavelengths based on filterValue number value print “Filter Value currently at:”, filterWheelIndex(filterValue) def counterclockwiseRotation(): GPIO.output(24, GPIO.HIGH) int 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