Boceto que responde a ciertos comandos, ¿cómo se hace?

Muy bien, tengo un boceto Arduino medio completo en este momento. Básicamente, el boceto a continuación parpadeará un LED en un escudo de Kegboard-Mini si una serie de caracteres es igual a * {blink_Flow_A} * Sin embargo, el LED solo parpadea una vez con el boceto actual cargado en el Arduino. Me gustaría que el Arduino parpadee repetidamente hasta que se envíe el comando "detener" al Arduino. Finalmente me gustaría abrir una válvula, mantenerla abierta hasta que la válvula reciba el comando de cierre y luego cerrar la válvula. El boceto se parece a lo siguiente,

/*
 * kegboard-serial-simple-blink07
 * This code is public domain
 *
 * This sketch sends a receives a multibyte String from the iPhone
 * and performs functions on it.
 *
 * Examples:
 * http://arduino.cc/en/Tutorial/SerialEvent
 * http://arduino.cc/en/Serial/read
 */

 // global variables should be identified with _

 // flow_A LED
 int led = 4;

 // relay_A
 const int RELAY_A = A0;

 // variables from sketch example
 String inputString = ""; // a string to hold incoming data
 boolean stringComplete = false; // whether the string is complete

 void setup() {

   Serial.begin(2400); // open serial port, sets data rate to 2400bps
   Serial.println("Power on test");
   inputString.reserve(200);

   pinMode(RELAY_A, OUTPUT);
}

void open_valve() {

  digitalWrite(RELAY_A, HIGH); // turn RELAY_A on

}

void close_valve() {

  digitalWrite(RELAY_A, LOW); // turn RELAY_A off
}

void flow_A_blink() {

  digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for one second
  digitalWrite(led, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

void flow_A_blink_stop() {

  digitalWrite(led, LOW);
}

void loop() {
  // print the string when newline arrives:
  if (stringComplete) {
    Serial.println(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }

  if (inputString == "{blink_Flow_A}") {
    flow_A_blink();
  }
}

//SerialEvent occurs whenever a new data comes in the
//hardware serial RX.  This routine is run between each
//time loop() runs, so using delay inside loop can delay
//response.  Multiple bytes of data may be available.

void serialEvent() {
  while(Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

Si hay alguna diferencia, alguien en el IRC me dijo que investigara las máquinas estatales.rasca la cabeza

Respuestas a la pregunta(4)

Su respuesta a la pregunta