Problems with Leonardo + Arduino Wireless Shield + Motorshield

Hi,

I’ve used a stacked Leonard, with Arudino Wireless SD Shield using an xBee series 1, and Adafruit Motorshield v1 with no problems (it’s on a robot platform).

From the other xbee (on a breadboard), I was able to control my robot however I wanted. Any push of a button attached to the xBee could be viewed easily on the serial monitor when the robot is attached to the USB.

Recently, I switched to Adafruit motorshield v2. I used the sample code provided with no problems at all when it is only this shield and the Leonardo attached. However, when I tried to stack the wireless shield on top of it, I ran into a problem in that I cannot view any data coming across the line on the serial monitor when I push a button in a very slightly modified code:

/* 
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2 
---->	http://www.adafruit.com/products/1438
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.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); 

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

int incomingByte;


void setup() 
{
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
  
  // Set the speed to start, from 0 (off) to 220 (max speed)
  myMotor->setSpeed(150);
  myMotor->run(FORWARD);
  // turn on motor
  myMotor->run(RELEASE);
}

void loop() {
  
  // can you see data transmitted from the other xBee?
  incomingByte = Serial1.read(); // read the oldest byte in the serial buffer
  Serial.println(incomingByte);
  
 /* 
  uint8_t i;
  
  Serial.print("tick");

  myMotor->run(FORWARD);
  for (i=0; i<220; i++) {
    myMotor->setSpeed(i);  
    delay(10);
  }
  for (i=220; i!=0; i--) {
    myMotor->setSpeed(i);  
    delay(10);
  }
  
  Serial.print("tock");

  myMotor->run(BACKWARD);
  for (i=0; i<220; i++) {
    myMotor->setSpeed(i);  
    delay(10);
  }
  for (i=220; i!=0; i--) {
    myMotor->setSpeed(i);  
    delay(10);
  }

  Serial.print("tech");
  myMotor->run(RELEASE);
  delay(1000);
  
*/  
}

It is actually very difficult to get the code to download, and I’ve often had to remove the wireless shield entirely to download. It’s only once this occurs, then I add the wireless shield back on to run the code. When the wireless shield is attached, my pc has a very difficult time downloading to the Leonardo. It keeps giving me the following error when I try to download (on the correct COM port - as indicated by the device manager):

Found programmer: Id = “BÛ/”; type =
Software Version = . ; Hardware Version = .
avrdude: error: buffered memory access not supported. Maybe it isn’t
a butterfly/AVR109 but a AVR910 device?

Any ideas? One thing I should note which is a good sign is that when I push a button, I do see that the TX led on the wireless shield lights up. But I’m not sure why this simple code snip-it works on v1 and not when added to v2, or why I cannot download when both boards are attached.