I don't understand how this all works

In addition to @kennethlimcp’s comment, the error messages are rather clear.

You haven’t declared any of the RELAYx variables in your code, and the #define statements present in the library are probably not visible in your .ino file, but even if they were they are not defined as all capital letters.

If you look at the examples in the library, you’ll see how to write the firmware for the Relay Shield
https://build.particle.io/libs/RelayShield/0.0.6/tab/example/3_Internet_Relays.cpp

And to check the function via the internet, you can go to
https://console.particle.io/devices
and trigger the exposed functions

To see how you can control your device otherwise, you can have a look at this tutorial
Tutorial: Spark Variable and Function on One Web Page

2 Likes