I am trying to let my stepper run as long as my Digital Input which is a Button is unpressed.
When its unpressed i get:
State [3]:1
ok
but my stepper is not moving only a little "clack" to hear.
Code: Select all
#! /usr/env/python
from Phidget22.Phidget import *
from Phidget22.Devices.DigitalInput import *
from Phidget22.Devices.Stepper import *
import time
def onStateChange(self, state):
	print("State [" + str(self.getHubPort()) + "]: " + str(state))
	if state == 1:
		print("ok")
		mot4 = Stepper()
		mot4.setHubPort(0)
		mot4.setDeviceSerialNumber(682067)
		mot4.openWaitForAttachment(4000)
		mot4.setTargetPosition(100000)
		mot4.setEngaged(True)
		mot4.close()
	else:
		print("nope")
def main():
	digitalInput3 = DigitalInput()
	digitalInput3.setIsHubPortDevice(True)
	digitalInput3.setHubPort(3)
	digitalInput3.setDeviceSerialNumber(682056)
	digitalInput3.setOnStateChangeHandler(onStateChange)
	digitalInput3.openWaitForAttachment(5000)
	try:
		input("Press Enter to Stop\n")
	except (Exception, KeyboardInterrupt):
		pass
	digitalInput3.close()
main()
Thanks for the help