Help me understand arduno code.

Hello, About a year ago I started learning Arduino and now I am movig into more complex and advanced stuff. Right now I am interested in mixing processing and arduino. I found this oscilloscope and I'm trying to figure out how it works. Can someone explain me the arduino code? Like what it does and why it does it that way?

Thank you and sorry for bad english.

Arduino code:

#define ANALOG_IN 0

void setup() {

void loop() {
  int val = analogRead(ANALOG_IN);                                              
  Serial.write( 0xff );                                                         
  Serial.write( (val >> 8) & 0xff );                                            
  Serial.write( val & 0xff );

analogRead returns a ten bit value, so that won't fit into a single byte, so it is sent to the PC as two bytes, plus a marker byte, though that could be ambiguous, because the least significant byte could be 255 too.

The high byte of the result is transferred first, so the first byte after a (sequence of) 0xFF is always the highpart of the value.

Ok, got it. Thank you very much.