Hi all,
I'm new to arduino/electronics/coding so forgive me if the answer is very obvious.
I'm trying to rotate a bipolar Nema 17 stepper with 200 steps (42shd0404-22) very slowly, about 1 step every 15 mins. This is to slowly stretch silicone that I'll be growing cells on in the lab. I'm using an arduino nano and an a4988 stepper driver. The transition between steps doesn't need to be especially smooth).
I can get the motor to rotate in both directions as instructed, but encounter problems when there is much more than about 30 seconds delay between steps. With longer than 30ish seconds the motor doesn't step and nothing at all seems to happen. I wired the boards and motor in the manner described by Howtomechatronix at How To Control a Stepper Motor with A4988 Driver and Arduino - YouTube so I think everything is wired correctly.
Here is the code that I'm using: (set to rotate in both directions by 100 steps with 30 seconds between steps):
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// this version uses delay() to manage timing
byte directionPin = 4;
byte stepPin = 3;
int numberOfSteps = 100;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 30000; // milliseconds
void setup() {
Serial.begin(9600);
}
void loop() {
delay(2000);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
digitalWrite(directionPin, HIGH);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
}
delay(3000);
digitalWrite(directionPin, LOW);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
}
}