I wanted to see if you had any ideas for ways to get a stepper motor to increase speed in response to clicking a Wii joystick button?
I was able to figure out something to get the motor to run at a constant speed by pressing the Z button and to release by pressing the C button. Now I am trying to figure out a way to increase speed with new presses of the Z button (while maintaining the ability to release it by pressing C).
Here is what I am using now (I just used a large number in the range so that it would keep looping). Indentation is correct in the actual code:
Code: Select all
elif nc.buttons.Z:
for i in range(100000):
if nc.buttons.C:
kit.stepper2.release()
break
#if Z is pressed and no button C press detected
else:
kit.stepper2.onestep(direction=stepper.FORWARD, style=stepper.MICROSTEP)
time.sleep(0.05)
else:
kit.stepper2.release()
time.sleep(0.5)