Serial communication problem?

Hello All,

I am trying to send serial data from a Fio V2 to an Uno R3 via Xbee series 1 radios. My Uno is receiving the data but it seems to have extra data that is not being sent from the Fio.

Going back to the beginning I took a closer look at the data coming out of the Fio, and when the I.R. receiver detects nothing it produces an uninterrupted steam of 1s. When it detects an object it streams 0, 1, 0, 1.... and not a steady stream of 0s as I was expecting.

Can anyone point me in the right direction with what is going on and what I need to research? I have posted the Fio code below and can post the Uno code later if needed.

Thanks in advance,

Z

unsigned long uSecsOld = 0;
boolean markFlag = true;
unsigned int markTime = 1000;                      //uSecs
unsigned int spaceTime = 2000;                     //uSecs

const int SigPin = 13;                             // the pin that the LED is attached to 11 (Uno)
const int ReceiverPin = 7;                         // Could use "Byte"?

void setIrModOutput()                              // sets pin 3 going at the IR modulation rate
{
  TCCR2A = 0xF0 | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS21);
  OCR2A = 66;                                      // defines the frequency 51 = 38.4 KHz, 54 = 36.2 KHz, 58 = 34 KHz, 62 = 32 KHz, 66 = 30KHz, 33 = 60 KHz
  OCR2B = 44;                                      // deines the duty cycle - Half the OCR2A value for 50%
}


void setup() 
{
  setIrModOutput();

  Serial.begin(9600);                              // initialize serial communication:
  
  pinMode(03, OUTPUT);                             // Just enable output on Pin 3 and disable it on Pin 11
  pinMode(ReceiverPin, INPUT);                     // I. R. Reviever pin
  pinMode(SigPin, OUTPUT);
  
  uSecsOld = micros();
}


void loop()
{
  char data = digitalRead(ReceiverPin);
  Serial.println(data, '0');
  Serial.flush();
  
 if (data == LOW)
  {
  //Serial.println ("Object Detected");
  digitalWrite(SigPin, HIGH);
  }

 else 
  {
  //Serial.println ("Scanning");
  digitalWrite(SigPin, LOW);
  }

  if (markFlag && ((micros() - uSecsOld) > markTime) ) 
    {
    //end of MARK
    uSecsOld = micros();
    OCR2B = OCR2A; //set SPACE
    markFlag = false;
    }
    
  else if (!markFlag && ((micros() - uSecsOld) > spaceTime) ) 
    {
    //end of SPACE
    uSecsOld = micros();
    OCR2B = 44; //set MARK
    markFlag = true;
    }
}