I'm developing a star tracker project and I cant figure out how to get the stepper motor to move. Can someone please help me write a simple test code to get the motor to work, or maybe the problem is with the connections. I'm currently a total noob in this and help would be appreciated ![]()
Where did you get the idea for the diagram from ?
I’m sure there’s some code there as well.
Show us what you’ve tried.
For the TMC2209, you will need Hardware Serial TMC2209/examples/UnidirectionalCommunication/StepAndDirection/StepAndDirection.ino at main · janelia-arduino/TMC2209 · GitHub
For other stepper drivers:
// Define pin connections & motor's steps per revolution
const int dirPin = 9;
const int stepPin = 11;
const int stepsPerRevolution = 400;
void setup()
{
// Declare pins as Outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop()
{
// Set motor direction clockwise
digitalWrite(dirPin, HIGH);
// Spin motor slowly
for(int x = 0; x < stepsPerRevolution; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(2000);
digitalWrite(stepPin, LOW);
delayMicroseconds(2000);
}
delay(1000); // Wait a second
// Set motor direction counterclockwise
digitalWrite(dirPin, LOW);
// Spin motor quickly
for(int x = 0; x < stepsPerRevolution; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
delay(1000); // Wait a second
}
Ive tried this code from this tutorial In-Depth: Control Stepper Motor with A4988 Driver Module & Arduino . And I also changed my driver to an 4988 temporarily so this code is for a4988
oh, i dont have my enable wired anywhere, my reset and sleep are connected together
Enable HIGH is disabling driver...
right thanks
don't understand the blue line between sleep and reset.
would be best to wire Reset HIGH (Vdd) and as @kmin pointed out, Enable LOW (ground)
did you also separately wire Vdd and Vmot? And tie all the gnds together on both boards
Okay, ill try connecting all the grounds together and wiring reset to vdd. Thank you
/SLEEP - logic high allows normal operation
/RESET - STEP inputs are ignored until the /RESET input is set to high
ok. make sure this is HIGH as well
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

