Problem running stepper motor and IMU simultaneously

I recently purchased a NEMA 17 stepper motor with the Adafruit Motor/Stepper Shield. I followed their tutorial and was able to successfully run the example code. The stepper motor worked just fine. I also have an MPU9150, which I was able to get working when I used it by itself. My problem is that when I try and run both the stepper motor and the IMU at the same time, neither seems to work. I verified that the I2C addresses for the two devices are different. The code that I am using is posted below… any pointers as to what I am doing wrong would be greatly appreciated (I know that it is likely something very simple). Note that the PID code is commented out only because I will be using it later.


#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <PID_v1.h>
#include "I2Cdev.h"
#include "MPU6050.h"

MPU6050 accel(0x68);

int16_t ax, ay, az;

Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x60);
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);  //Adding stepper motor with 200 steps per revolution to port 2 (M3 and M4)

//double TMDsetpoint = 0.00;
//double TMDinput, TMDoutput;
//double kp = 1.00, ki = 0.00, kd = 0.00;
//PID TMDPID(&TMDinput, &TMDoutput, &TMDsetpoint, kp, ki, kd, DIRECT);

void setup(){
  myMotor->setSpeed(10);  //10 rpm

void loop(){
  accel.getAcceleration(&ax, &ay, &az);
  Serial.print("ax,ay,az   "),Serial.print(ax),Serial.print("\t"),Serial.print(ay),Serial.print("\t"),Serial.println(az);
  //TMDinput = ax;

  myMotor->step(100, FORWARD, DOUBLE); 
  myMotor->step(100, BACKWARD, DOUBLE);


my battery was getting low

Stepper motors are very inefficient and are not really suited to battery power.

Stepper Motor Basics