Xbee Communication bwtween a Computer and an Arduino

Here I have a very basic setup with an Arduino and XBee 2.5 modules. I used this sample code to configure the Communication between the two and it seems to work fine. IN X-CTU, I get the testing… message every second so I think my connections and settings should be fine.

#define ledPin 13
byte pinState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
void loop() {
// toggle an LED just so you see the thing's alive.
void toggle(int pinNum) {
// set the LED pin using the pinState variable:
digitalWrite(pinNum, pinState);
// if pinState = 0, set it to 1, and vice versa:
pinState = !pinState;

The problem comes when I want to send data to my Arduino. I have flashed my Arduino with this code:

  Physical Pixel
 An example of using the Arduino board to receive data from the 
 computer.  In this case, the Arduino boards turns on an LED when
 it receives the character 'H', and turns off the LED when it
 receives the character 'L'.
 The data can be sent from the Arduino serial monitor, or another
 program like Processing (see code below), Flash (via a serial-net
 proxy), PD, or Max/MSP.
 The circuit:
 * LED connected from digital pin 13 to ground
 created 2006
 by David A. Mellis
 modified 30 Aug 2011
 by Tom Igoe and Scott Fitzgerald
 This example code is in the public domain.


const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);

/* Processing code for this example
 // mouseover serial 
 // Demonstrates how to send data to the Arduino I/O board, in order to 
 // turn ON a light if the mouse is over a square and turn it off 
 // if the mouse is not. 
 // created 2003-4
 // based on examples by Casey Reas and Hernando Barragan
 // modified 30 Aug 2011
 // by Tom Igoe
 // This example code is in the public domain.

 import processing.serial.*; 
 float boxX;
 float boxY;
 int boxSize = 20;
 boolean mouseOverBox = false;
 Serial port; 
 void setup()  {
 size(200, 200);
 boxX = width/2.0;
 boxY = height/2.0;
 // List all the available serial ports in the output pane. 
 // You will need to choose the port that the Arduino board is 
 // connected to from this list. The first port in the list is 
 // port #0 and the third port in the list is port #2. 
 // Open the port that the Arduino board is connected to (in this case #0) 
 // Make sure to open the port at the same speed Arduino is using (9600bps) 
 port = new Serial(this, Serial.list()[0], 9600); 
 void draw() 
 // Test if the cursor is over the box 
 if (mouseX > boxX-boxSize && mouseX < boxX+boxSize && 
 mouseY > boxY-boxSize && mouseY < boxY+boxSize) {
 mouseOverBox = true;  
 // draw a line around the box and change its color:
 // send an 'H' to indicate mouse is over square:
 else {
 // return the box to it's inactive state:
 // send an 'L' to turn the LED off: 
 mouseOverBox = false;
 // Draw the box
 rect(boxX, boxY, boxSize, boxSize);

With the USB connection, this code works in Processing. When I input the letter ‘H’ or ‘L’ in the Serial Monitor of Arduino 1.0, it seems to work fine too.However, when I disconnect the USB cable and reconnect the TX0/RX0 of my Arduino Mega an try to input the same thing in the X-CTU Terminal, nothing happens. Below is a picture of my setup. As I am at home, it is currently powered by a USB hub at the moment. In this situation, is it because I am not using an Arduino Shield? I didn’t really think one would be necessary, as I will be making a PCB board for my project. What am I doing wrong? Thanks.