There’s a neat tutorial in functions over here that has helped me in the past: Tutorial: Spark Variable and Function on One Web Page
Here’s a small demo:
void setup() {
Serial.begin(9600);
Particle.function("passText", handleText);
}
void loop() {
}
//Normally you should keep this as short as possible.
//For simplicities sake, I've put it in the function handler.
//in real-life, but it in the loop, and only set a 'flag' here.
int handleText(String actualText){
RGB.control(true);
RGB.color(0,255,0);
Serial.println(actualText);
Particle.publish("eventNameHere", actualText);
delay(1000);
RGB.control(false);
return 0;
}
Put that on your device. Then, log in over here. You should see your devices, their variables and functions. Click on the blue button on the bottom, and keep both pages open. Then, on the first page, enter something in the “passText” function, and click send. You should then see that pop up in the second screen