How to turn on LED on Arduino when it recognises new XML data

Hi there,

I’ve been searching for a while about how to get an LED to turn on when a message is sent through a php form using serial connection, not ethernet.

I have a php form that sends a message to a database.
http://praxis.cit.ie/~rebeccanoonan/persistence1/rnoonan/form2.php

The message also shows up as xml on a separate webpage.
http://praxis.cit.ie/~rebeccanoonan/persistence1/rnoonan/messageresults.php

I have managed to get the messages showing up in the Processing monitor when a new message is sent. I’m taking the information from the messageresults page.

This is the code I used to do this:

XML xml;

void setup() {
  xml = loadXML("http://praxis.cit.ie/~rebeccanoonan/persistence1/RNoonan/messageresults.php");
  
  XML[] msgs = xml.getChildren("message");

  for (int i = 0; i < msgs.length; i++) {
    String content = msgs[i].getContent();
    println("message is :" + content );
  }
}

I’ve tested a simple read/write example between Arduino and Processing already so that a LED lights on the Arduino when I click on a square in Processing but I’m not sure where to go from here even after looking around on Google for a good while.

Can anyone point me in the right direction in order to get a LED on an Arduino Uno light up through serial communication when Arduino recognises that a new message is sent through the form?

Thank you in advance.

You might look at the below application.

http://playground.arduino.cc/Code/TextFinder#.UwqRSiko7iw

but I'm not sure where to go from here even after looking around on Google for a good while.

You have some data in the Processing app. What do you want to send to the Arduino? What do you want it to do with it?

I want to send the incoming messages in Processing to Arduino, or just make Arduino recognise that someone has submitted a new message through the form. All I want it to do is turn on a LED once it receives this data by using USB.

if (content == "led on")
  digitalWrite(LED_PIN, HIGH);
else if (content == "led off")
  digitalWrite(LED_PIN, LOW);

what else?

I want to send the incoming messages in Processing to Arduino

You've got that covered:

I've tested a simple read/write example between Arduino and Processing already so that a LED lights on the Arduino when I click on a square in Processing

It isn't rocket science to figure out which portion of that code established the serial port connection to the Arduino. It is brain surgery to figure out which portion of that code sent the message.

or just make Arduino recognise that someone has submitted a new message through the form.

That's a different requirement. It still requires that Processing establish a serial connection and send something.

All I want it to do is turn on a LED once it receives this data by using USB.

Too bad. You ACTUALLY have to write code to detect that there is serial data. Reading it is probably a good idea too.