I am trying to control two stepper motors with the Adafruit Motor Sheild V2 from Arduino Uno. I was able to get it to upload and run, but now it will not upload any changes (or even the exact same thing again). Upon uploading I simply get the error "Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions." with no more information.
This is the sketch information
// Shows how to run three Steppers at once with varying speeds
//
// Requires the Adafruit_Motorshield v2 library
// GitHub - adafruit/Adafruit_Motor_Shield_V2_Library: Arduino library for Adafruit Motor Shield v2!
// And AccelStepper with AFMotor support
// GitHub - adafruit/AccelStepper: A small fork of AccelStepper v1.3 with AF_motor (Adafruit motor shield) support!
// This tutorial is for Adafruit Motorshield v2 only!
// Will not work with v1 shields
#include <Wire.h>
#include <AccelStepper.h>
#include <Adafruit_MotorShield.h>
Adafruit_MotorShield AFMSbot(0x61); // Rightmost jumper closed
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
// Connect two steppers with 200 steps per revolution (1.8 degree)
// to the top shield
Adafruit_StepperMotor *myStepper1 = AFMStop.getStepper(200, 1);
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 2);
// Connect one stepper with 200 steps per revolution (1.8 degree)
// to the bottom shield
Adafruit_StepperMotor *myStepper3 = AFMSbot.getStepper(200, 2);
// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
void forwardstep1() {
myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
myStepper1->onestep(BACKWARD, SINGLE);
}
// wrappers for the second motor!
void forwardstep2() {
myStepper2->onestep(FORWARD, DOUBLE);
}
void backwardstep2() {
myStepper2->onestep(BACKWARD, DOUBLE);
}
// wrappers for the third motor!
void forwardstep3() {
myStepper3->onestep(FORWARD, INTERLEAVE);
}
void backwardstep3() {
myStepper3->onestep(BACKWARD, INTERLEAVE);
}
// Now we'll wrap the 3 steppers in an AccelStepper object
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);
AccelStepper stepper3(forwardstep3, backwardstep3);
void setup()
{
AFMSbot.begin(); // Start the bottom shield
AFMStop.begin(); // Start the top shield
stepper1.setMaxSpeed(100.0);
stepper1.setAcceleration(100.0);
stepper1.moveTo(24);
stepper2.setMaxSpeed(200.0);
stepper2.setAcceleration(100.0);
stepper2.moveTo(50000);
stepper3.setMaxSpeed(300.0);
stepper3.setAcceleration(100.0);
stepper3.moveTo(1000000);
}
void loop()
{
// Change direction at the limits
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
if (stepper3.distanceToGo() == 0)
stepper3.moveTo(-stepper3.currentPosition());
stepper1.run();
stepper2.run();
stepper3.run();
}
I commented out motor 3 and some moves as I don't want them. I simply want to control the speed of 2 motors in opposite directions of each other.