char val;          // variable to receive data from the serial port
int serbyte;
int ledpin = 13;   // LED connected to pin 12

void setup() 
{
  pinMode(ledpin, OUTPUT);  // pin 12 as OUTPUT
  beginSerial(9600);        // initialize serial port
}

//this doesn't work like wiring, our serial control is much more powerful
//void serialEvent2()
//{
//  val = serial;             // get data received in val
//}

void loop() {
  serbyte = uartGetByte();
  if (serbyte != -1) {
    val = serbyte;
  }
  if(val == 'H')                   // if receive an 'H'
  {
    digitalWrite(ledpin, HIGH);    // turn ON the LED
  } else { 
    digitalWrite(ledpin, LOW);     // if not turn it OFF
  }
  delay(100);                      // wait 100ms for next reading
}
