I've got an adafruit v2 motor shield which works fine. However, the obvious place to drive the stepper is inside an Interrupt Service Routine. Why? Because if you drive in inside loop then anything you do in the foreground changes the motor speed and slow things like updating an LCD display cause the motor to stutter badly. So, I have the usual suspects for setting up the stepper:
Code: Select all
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
Adafruit_StepperMotor *myStepper1 = AFMStop.getStepper(200, 2);
void forwardstep1() {
myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
myStepper1->onestep(BACKWARD, SINGLE);
}
Which gets us the forwardstep1 and backwardstep1 routines. If I call those routines from inside loop, everything is fine. If I call them from inside an ISR then we crash and burn. Any suggestions?