Serial.print prints random 255

Hey,
I am working on a Mac app to control my Arduino and everything works but if I send the values 0-63 to the Arduino using the following code on the Arduino:

void setup() {
  Serial.begin(2000000);
  Serial.print("\n\nHello, I just rebooted\n\n");
}

void loop() {
  uint8_t incomingByte[2];
  // send data only when you receive data:
  if (Serial.available() > 0) {

    for (int i = 0; i < 2; i+=2){
      // read the incoming byte:
      incomingByte[i] = Serial.read();
      incomingByte[i+1] = Serial.read();
    }
    Serial.println(incomingByte[0], DEC);
    Serial.println(incomingByte[1], DEC);
    delayMicroseconds(5000);
  }
}

The print out should read 0-63 but what it reads is:
0
255
1
2
3
4
...
62
63
255

The shorter the delay that I put in the more 255 appear. Any idea on what could be happening?

Thanks
-Korki

Why do you have your baud rate @ 2000000?

Try setting it to 9600 and see what happens....

hint:
byte test = -1;

:]

I had the baud rate at 2000000 because thats the highest the mac can handle and I was just trying a bunch of things. I have it working now with 500 microsecond delays after the first and second read. Its working at least for now.

Thanks
-Korki

You test to see if there is at least one byte in the receive buffer, then you always read two.
(I wish I had a quid for every time that has been written on this forum)

Haha. I totally forgot about that. My computer crashed so I had to start over. and never changed that. I feel like and idiot now.

-Korki