Search wiring.org.co:

This example is for Wiring version 1.0 build 0100+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

This example demonstrates Messenger's checkString method It turns on the LED attached to pin 48 if it receives "on" It turns it off if it receives "off"

    #include <Messenger.h>

    // Instantiate Messenger object with the message function and the default separator
    // (the space character)
    Messenger message = Messenger();

    // Define messenger function
    void messageCompleted() {
      // This loop will echo each element of the message separately
      while ( message.available() ) {
        if ( message.checkString("on") ) {
          digitalWrite(WLED,HIGH);
        } else if ( message.checkString("off") ) {
          digitalWrite(WLED,LOW);
        }
      }

    }

    void setup() {
      // Initiate Serial Communication
      Serial.begin(115200);
      message.attach(messageCompleted);

      pinMode(WLED,OUTPUT);

    }

    void loop() {

      // The following line is the most effective way of
      // feeding the serial data to Messenger
      while ( Serial.available() ) message.process( Serial.read() );

    }