I don't understand how this all works

Hi @Bobzilla

The sample code does indeed work fine, you just didn't cut and paste all of it. Not a big deal. The relays are defined at the top of the sample:

int RELAY1 = D3;
int RELAY2 = D4;
int RELAY3 = D5;
int RELAY4 = D6;

An "exposed function" is something you declare using Particle.function(). It is a way of letting you use the Particle cloud to call a function remotely on your Photon or Electron. A Particle function always takes a String argument and returns and int that generally indicates success or failure of the call, but you can decide what it means.

Here is a link to a tutorial I wrote a long time ago using both functions and variables. Note that Spark.function is now Particle.function and a few other small changes.

You will see that you don't need your own webserver to use any of this--any modern browser will work. If you do have a webserver, that can let you do more advanced things, but it is not required.

4 Likes