Hey everyone, after a bunch of research, I'm still having trouble with this issue. I simply want to de-energize my stepper motor after executing a move. I do not need it to hold position. So I have found a few things I thought would help but I'm clearly missing something.
I have tried putting the "release()" command in to no avail. I occasionally get an error depending on where I put it, and other times i dont get an error, but it still won't de-engergize. sketch as follows.
This does everything but de-energize, turns on the LED, turns the motor and stops. Fairly simple setup.
#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);
//Naming the buttons
int buttonApin = 2;
int buttonBpin = 3;
int ledPin = 6;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
myMotor->setSpeed(50); // 10 rpm
AFMS.begin(1600); // create with the default frequency 1.6KHz
}
void loop()
{
int sensorVal = digitalRead(2);
{
if (digitalRead(buttonApin) == LOW)
{
digitalWrite(ledPin, HIGH);
myMotor->step(100, FORWARD, DOUBLE);
digitalWrite(ledPin, LOW);
delay(500);
}
}
}