Hi, I am using a S3 Feather with a DC Motor + Stepper Add-On.
I am trying to change the parameters (pwm_frequency and steppers_microsteps) in code, depending upon motions with a Wii joystick. I am using if statements to match the joystick position to the motor (e.g. if x axis joystick position = 255, motor action is microsteps, if y axis joystick position is 255, motor action is interleave).
I have been trying to alter the pwm_frequency and steppers_microsteps properties further down in the code (after creating the MotorKit instance) but I can't figure out how to do it.
This is how I set up the instance of the MotorKit at the beginning (I get an error if I try to include pwm_frequency so I deleted it. steppers_microsteps changes work, e.g. change to 4, 8, 16):
i2c_bus = board.I2C()
kit = MotorKit(i2c=i2c_bus, steppers_microsteps=16)
Further down in the program, here is how I am trying to change steppers_microsteps and pwm to respond to an if statement:
elif y == 255:
steppers_microsteps=64
pwm_frequency=1400
kit.stepper2.onestep(direction=stepper.FORWARD, style=stepper.MICROSTEP)
time.sleep(0)
Is it possible to change the microsteps like this? I do not get an error from the elif above, but changing the numbers (microsteps and frequency) has no effect. Thank you!
Stepper/MotorKit question
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
Please be positive and constructive with your questions and comments.