Viewing output from Serial.write

wengzhe:
I understand that Serial.write writes binary data to the serial port.
Is there a way to view what has been written?

You might try printing the bytes to the serial monitor in hex format to see what they are. Below is some test code for the serial monitor.

// zoomkat 5-28-13 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial test 0021"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(2);  //delay to allow byte to arrive in input buffer
    byte c = Serial.read();
    //char c = Serial.read();
   // print it out in many formats:
   //Serial.println(c);       // print as an ASCII-encoded decimal
   Serial.println(c, DEC);  // print as an ASCII-encoded decimal
   Serial.println(c, HEX);  // print as an ASCII-encoded hexadecimal
   Serial.println(c, OCT);  // print as an ASCII-encoded octal
   Serial.println(c, BIN);  // print as an ASCII-encoded binary
   Serial.println();

    readString += c;
  }

  if (readString.length() >0) {
    Serial.println("Decimal values of bytes sent");
    Serial.println(readString);
    Serial.println("Done!");
    Serial.println();
    readString="";
  } 
}