TLDR: Can I use the Stepper.h library in Arduino using the setup shown in my drawing, or do I have to switch it up?
So I'm trying to control my NEMA 23 stepper motor (Link) using this stepper driver via my Arduino.
I've got it working just fine with the setup shown for what I need at the moment using digitalWrite(pin, HIGH/LOW)
, but as my project gets more complicated I would like to be able to streamline my code and make it less messy and more efficient.
I've been reading up on the <Stepper.h>
library and it looks great and exactly like what I need, but I'm having trouble figuring out how to connect everything. Every tutorial I've seen either uses the driver I'm using (or one like it) or the stepper motor library.
I've tried looking through the docs, but they don't really specify what the different pins mean when establishing the stepper object in Arduino:
Stepper(steps, pin1, pin2)
pin1, pin2: two pins that are attached to the motor.
Like what does that even mean. I have to assume they can't just be attached willynilly.
Here is a crude drawing of how I have it set up now: (please ignore the change in color of the wires going from the stepper motor to the driver).
This setup has been working well without using the stepper library, but I've been having trouble when trying to implement <Stepper.h>
. I wasn't sure which pins were pin1 and pin2, so I used what had been working before when I had one pin for Pulse and one for Direction:
Stepper myStepper(steps_per_rev, 8, 9);
However, that has not been working, so I've been assuming that the setup needs to be different. (however, it could also be some small bug in my code that I'm not seeing at the moment).