Project Help!! Not able to upload code to arduino board.

I am doing a project on farm monitoring.
It involves a network of zigbee routers (currently 2 routers). each with 3 sensor attached.
The coordinator is receiving i/o packets from these router, as checked on xctu.

I wanted to mount the coordinator on arduino, so that I can view packets received on serial monitor.
But I am not able to upload the code onto the board. It is getting compiled successfuly .

It shows issues /error messages like “com port busy” or “board can’t be accessed” or some sync issue.

Both arduino and zigbee are at 9600 baud rate.

The code I wrote was:

void setup()
{ Serial.begin(9600);
}
void loop()
{
if(Serial.available()>=21)
{
for(int i=0;i<22;i++)
{
Serial.print(Serial.read,HEX);

 /* I tried replacing this line with  Serial.print(Serial.read());*/
/* I also tried
   byte now= Serial.read();
   Serial.print(now,BYTE);

*/
}
}
}

The connections I made were:

arunio vcc –> xbee vcc
arduino gnd –> xbee gnd
arduino tx –>xbee rx
arduino rx –>xbee tx

Please suggest what can be done to solve this issue.

What voltage level is your Arduino running at?

Oh and what code are you having issues with and how are you trying to upload it?