   digitalWrite(ledTargetPin, LOW);
   delay(500);
 }
-
-// void serialEvent() {
-//   while (Serial.available()) {
-//     // get the new byte:
-//     char inChar = (char)Serial.read(); 
-//     // add it to the inputString:
-//     inputString += inChar;
-//     // if the incoming character is a newline, set a flag
-//     // so the main loop can do something about it:
-//     if (inChar == '\n') {
-//       Serial.println("string complete");
-//       stringComplete = true;
-//     } 
-//   }
-// }
 
 void enterCommandMode() {
   delay(2000);

/*
  XBee test on Mega

  For old code that works with Aruidno Uno, see git log and pull it from the repo

  Modified upon "Mega multple serial test"
  
  Receives from the main serial port, sends to the others. 
  Receives from serial port 2 (XBee), sends to the main serial (Serial 0).
 
  This example works only on the Arduino Mega
 
  created 07/25/2013
  by Ben Zhang <benzh@eecs.berkeley.edu>
 
 */
#include <SoftwareSerial.h>

// #define XBee Serial2

SoftwareSerial XBee(3,2);
int ledStatePin = 13;

char XBeeInString[50];

void setup() {
  pinMode(ledStatePin, OUTPUT);
  pinMode(ledSignalPin, OUTPUT); 
  pinMode(controlledPin, OUTPUT);
  pinMode(ledTargetPin, OUTPUT); 

  // initialize both serial ports:
  Serial.begin(9600);
  XBee.begin(9600);
  Serial.println("ready!");

  // uncomment the one that you want to use
  enterCommandMode();
  // setID(13);
  // setChannel(4321);
  readID();
  readChannel();
  writePermanent();
  exitCommandMode();

  Serial.println("done!");
}

void loop() {
  // some useless loop, just indicating the code is running
  digitalWrite(ledStatePin, HIGH);
  delay(500);
  digitalWrite(ledStatePin, LOW);
