arduino uno with xbee series 2:problem with sync

Hi!I have a problem with my arduino and my xbee series 2.When i connect the transmitter to the usb board and then to the pc,and the receiver to the arduino shield,and try to upload the program from pc to arduino,arduino ide tell me “avrdude: stk500_getsync(): not in sync: resp=0x00 …”.

Why?

Usb board:

http://www.robot-italy.com/en/xbee-usb-board.html

shield xbee that i use now:

http://www.robotshop.com/content/PDF/be … 119b2p.pdf

arduino is powered externally with a 9V battery like this:

http://www.arduino.cc/playground/Learni … eryAdapter

ps:on the arduino,i have a motor shield and the bees shield.The motorshield is this:

http://www.dfrobot.com/wiki/index.php?t … ld_(L298N)_(SKU:DRI0009

Program code(don’t see the command of IR sensor):

char comando, vel;

int velocita=255;

const int pinsensore=2;

int statesens=HIGH;

void setup(){

Serial.begin(9600);

pinMode(6,OUTPUT);

pinMode(7,OUTPUT);

pinMode(4,OUTPUT);

pinMode(5,OUTPUT);

pinMode(pinsensore,INPUT);

}

void loop(){

/*if(digitalRead(pinsensore)==LOW)

{

stop();

back();

delay(500);

left();

delay(1500);

go();

}*/

if(Serial.available()>0){

comando=Serial.read();

Serial.println(comando);

switch(comando){

case ‘g’: go();break;

case ‘s’: stop(); break;

case ‘b’: back(); break;

case ‘r’: right(); break;

case ‘l’: left(); break;

case ‘m’: delay(500);

vel=Serial.read();

if(vel==‘1’) velocita=100;

else if(vel==‘2’) velocita=180;

else if(vel==‘3’) velocita=255;

if(vel) Serial.println(“Velocita’ modificata”);

break;

}

}

}

void go(){

//Motore sinistro

digitalWrite(7,LOW);

analogWrite(6,velocita);

//Motore destro

digitalWrite(4,LOW);

analogWrite(5,velocita);

}

void stop(){

//Motore sinistro

digitalWrite(7,LOW);

analogWrite(6,0);

//Motore destro

digitalWrite(4,LOW);

analogWrite(5,0);

}

void back(){

//Motore sinistro

digitalWrite(7,HIGH);

analogWrite(6,velocita);

//Motore destror

digitalWrite(4,HIGH);

analogWrite(5,velocita);

}

void right(){

//Motore sinistro

digitalWrite(7,HIGH);

analogWrite(6,(255-velocita));

//Motore destro

digitalWrite(4,LOW);

analogWrite(5,velocita);

}

void left(){

digitalWrite(7,LOW);

analogWrite(6,velocita);

//Motore destro

digitalWrite(4,HIGH);

analogWrite(5,(255-velocita));

}

Photo of the complete robot:

http://imageshack.us/photo/my-images/22/imag0325w.jpg/

thanks!