0
$\begingroup$

So I am using a Seeeduino XIAO as my microcontroller which then connects to a ULN2003 board connected to a 28byj48 Stepper Motor. I have wired the Digital I/O pins from the XIAO as D1 -> In1 D2 -> In2 and so forth on the driver board. I am also using the 5V output from the XIAO to power ULN2003 board. I have been looking at the documentation for Circuit Python and Stepper Motors and can't figure out what's wrong with my code (or alternatively if my wiring is the problem). Below is a snippet of my Code:

import board
from digitalio import DigitalInOut
from adafruit_motor import stepper


pin1 = DigitalInOut(board.D1)
pin2 = DigitalInOut(board.D2)
pin3 = DigitalInOut(board.D3)
pin4 = DigitalInOut(board.D4)


motor1 = stepper.StepperMotor(pin1, pin2, pin3, pin4)

for i in range(100):
    motor1.onestep()
    time.sleep(.01)

I am unsure if I am even initializing the motor correctly, so any help would be appreciated!

$\endgroup$
1
  • 1
    $\begingroup$ I think you should edit to supply some more information: What are the symptoms? Is the rotor locked or free to rotate? Is any current flowing through the motor? What is the coil voltage (multimeter or oscilloscope reading)? Are you getting switching signals on pin1 - pin4? Schematic diagram? Links to datasheets for the motor, XIAO and ULN2003 board? $\endgroup$
    – Transistor
    Jun 25, 2022 at 7:45

1 Answer 1

0
$\begingroup$

As @Transistor commented, having any idea of what is happening or some links to some documentation would be "helpful."

That said, a little looking at the adafruit_motor package shows that it is expecting PWM inputs unless the last argument is None. Please try updating your motor1 line to read:

motor1 = stepper.StepperMotor(pin1, pin2, pin3, pin4, None)

and see if that works better. If it does, great. If not, tell us what you are seeing (and hearing).

$\endgroup$
2
  • $\begingroup$ Hey thanks for the reply, I was going to reformat everything and include links but I tried the Arduino library (since that's well documented with these components) and it worked first try, so I think ill just stuck with Arduino since it works. Thanks again! $\endgroup$
    – Geo
    Jun 25, 2022 at 22:15
  • $\begingroup$ Glad you got it going. Making it work is the first thing, something I keep forgetting "solving" problems that would go away if I looked for a simpler solution. $\endgroup$ Jun 26, 2022 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.