All pastes #2086377 Raw Edit

Stuff

public text v1 · immutable
#2086377 ·published 2011-10-03 03:54 UTC
rendered paste body
bool gotCmd=FALSE;
bool gotData=FALSE;

void loop() {
  if (Serial.available() > 0) {
    cmd = Serial.read();
    gotCmd = true;
  }
  if (Serial.available() > 0 && gotCmd) {
    num = int(Serial.read());
    gotData = true;
  }

  if (gotCmd && gotData) {
     // switch your stuff
     gotCmd = false;
     gotData = false;
  }
}