Wondering if anyone can shed some light on why my stepper motor doesn't stop? I have it hooked up correctly I believe and I am powering the board with 12v. The stepper turns when I upload the code to the Arduino but I am expecting it to stop after the amount of steps I tell it to go and it just keeps turning, not sure why... I am expecting it to go 10 steps but it keeps turning. The stepper motor I am using is like this one https://www.aliexpress.com/item/4000222246368.html. Also, is there a code repository somewhere that gives more information on how to use the board than the simple tutorial does? Code below:
Code: Select all
#include <Wire.h>
#include <Adafruit_MotorShield.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
myMotor->setSpeed(10); // 10 rpm
}
void loop() {
Serial.println("Double coil steps");
myMotor->step(10, FORWARD, DOUBLE);
}