Increasing speed with stepper

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
forum_questions_1
 
Posts: 111
Joined: Tue Oct 25, 2022 4:05 pm

Increasing speed with stepper

Post by forum_questions_1 »

Hi,

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)
Thanks for any ideas.
Last edited by dastels on Fri Dec 02, 2022 12:10 pm, edited 1 time in total.
Reason: Add code tags

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”